HAProxy.StreamProcessingOffload.AgentFramework
1.0.2
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
<PackageReference Include="HAProxy.StreamProcessingOffload.AgentFramework" Version="1.0.2" />
paket add HAProxy.StreamProcessingOffload.AgentFramework --version 1.0.2
#r "nuget: HAProxy.StreamProcessingOffload.AgentFramework, 1.0.2"
// 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
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); } }
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.
See example/haproxy to see how to configure haproxy. You will find extended information in the section 2 of the specification.
Product | Versions 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. |
-
net6.0
- Microsoft.AspNetCore.Connections.Abstractions (>= 6.0.19)
- Microsoft.AspNetCore.Hosting.Server.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.Server.Kestrel.Core (>= 2.2.0)
- Microsoft.Extensions.Configuration (>= 6.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.4)
- Microsoft.Extensions.Options (>= 6.0.0)
- NeoSmart.AsyncLock (>= 3.2.1)
- System.IO.Pipelines (>= 6.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.