HAProxy.StreamProcessingOffload.AgentFramework 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package HAProxy.StreamProcessingOffload.AgentFramework --version 1.0.2                
NuGet\Install-Package HAProxy.StreamProcessingOffload.AgentFramework -Version 1.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HAProxy.StreamProcessingOffload.AgentFramework" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HAProxy.StreamProcessingOffload.AgentFramework --version 1.0.2                
#r "nuget: HAProxy.StreamProcessingOffload.AgentFramework, 1.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install HAProxy.StreamProcessingOffload.AgentFramework as a Cake Addin
#addin nuget:?package=HAProxy.StreamProcessingOffload.AgentFramework&version=1.0.2

// Install HAProxy.StreamProcessingOffload.AgentFramework as a Cake Tool
#tool nuget:?package=HAProxy.StreamProcessingOffload.AgentFramework&version=1.0.2                

HAProxy Stream Processing Offload Agent Framework

Provides a Stream Processing Offload Protocol framework for ASP.NET Core or BedrockFramework.

It is fully asynchronuous and make heavy use of I/O Pipeline and Buffer to do high-performance I/O and protocol parsing.

Supports :

  • SPOP version 2.0 specification
  • All SPOP data types
  • Capabilities :
    • Fragmentation in both ways. Meaning it can read fragmented frame from HAProxy and is ready to write them when HAProxy will support it
    • Pipelining
  • SPOP Healthcheck

While it works fine and is production ready, some parts still need improvement. Contributions are welcome to improve :

  • end-user experience and configuration
  • add spop frame async capability (use an arbitrary connection to send agent ack frames)

Run examples

cd example
docker-compose up -d
curl -v http://localhost:8000

should show Ip_score response header

HTTP/1.1 GET /

Host: localhost:8000
Ip_score: 10
User-Agent: curl/7.68.0
Accept: */*

You can find agent source code in example/agent.

You may want to test bedrock flavor with docker compose -f docker-compose.yml -f docker-compose.bedrock.yml up.

Additionally, example folder contains a Dockerfile to build and run the HAProxy C example. You can run it with docker compose -f docker-compose.yml -f docker-compose.spoa-example.yml up and compare performance.

Usage

  1. Add a SpoaApplication class to handle messages sent by HAProxy and return actions

    public class SpoaApplication : ISpoaApplication
    {
        public Task<IEnumerable<SpopAction>> ProcessMessagesAsync(long streamId, IEnumerable<SpopMessage> messages)
        {
            var responseActions = new List<SpopAction>();
    
            foreach (var myMessage in messages)
            {
                if (myMessage.Name == "my-message-name")
                {
                    int ip_score = 10;
    
                    if (IPAddress.IsLoopback((IPAddress)myMessage.Args["ip"])) ip_score = 20;
    
                    SpopAction setVar = new SetVarAction(VarScope.Request, "ip_score", ip_score);
                    responseActions.Add(setVar);
                }
            }
    
            return Task.FromResult((IEnumerable<SpopAction>)responseActions);
        }
    }
    
  2. In Program.cs, Add Spoa Framework to a IWebHostBuilder.

    class Program
    {
        public static async Task Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }
    
        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder
                        .ConfigureServices(services =>
                        {
                            services.Configure<SpoaFrameworkOptions>(options =>
                            {
                                options.EndPoint = new IPEndPoint(IPAddress.Loopback, 12345);
                            });
                            services.AddSingleton<ISpoaApplication, SpoaApplication>();
                            services.AddSpoaFramework();
                        })
                        .UseStartup<Dummy>();
                });
    }
    
    internal class Dummy
    {
        public void Configure(IApplicationBuilder app)
        {
        }
    }
    

    Use your own Startup class if the Host is also serving Web content.

  3. See example/haproxy to see how to configure haproxy. You will find extended information in the section 2 of the specification.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 225 11/14/2023
1.0.2 152 7/1/2023
1.0.1 404 5/27/2022
1.0.0 445 12/30/2021