SlimFaasClient 0.72.2
dotnet add package SlimFaasClient --version 0.72.2
NuGet\Install-Package SlimFaasClient -Version 0.72.2
<PackageReference Include="SlimFaasClient" Version="0.72.2" />
<PackageVersion Include="SlimFaasClient" Version="0.72.2" />
<PackageReference Include="SlimFaasClient" />
paket add SlimFaasClient --version 0.72.2
#r "nuget: SlimFaasClient, 0.72.2"
#:package SlimFaasClient@0.72.2
#addin nuget:?package=SlimFaasClient&version=0.72.2
#tool nuget:?package=SlimFaasClient&version=0.72.2
<div align="center"> <a href="https://slimfaas.dev/"> <img src="https://raw.githubusercontent.com/SlimPlanet/SlimFaas/main/src/SlimFaasSite/public/slimfaas.svg" alt="SlimFaas" width="96" /> </a> </div>
SlimFaasClient
C# library to connect Jobs or virtual functions to SlimFaas via WebSocket. Lets any process receive async requests and publish/subscribe events without exposing an HTTP port.
Links:
- NuGet package: https://www.nuget.org/packages/SlimFaasClient
- GitHub repository: https://github.com/SlimPlanet/SlimFaas
- SlimFaas website: https://slimfaas.dev/
Installation
dotnet add package SlimFaasClient
Quick start
using SlimFaasClient;
var config = new SlimFaasClientConfig
{
FunctionName = "my-job",
SubscribeEvents = [new SubscribeEventConfig { Name = "order-created" }],
DefaultVisibility = FunctionVisibility.Public,
NumberParallelRequest = 5,
};
await using var client = new SlimFaasClient.SlimFaasClient(
new Uri("ws://slimfaas:5003/ws"), config);
// Async request handler — return the HTTP status code SlimFaas should record
client.OnAsyncRequest = async req =>
{
Console.WriteLine($"Request: {req.Method} {req.Path}{req.Query}");
// Body is available as a byte[]? decoded from base64
return 200;
};
// Publish/subscribe event handler
client.OnPublishEvent = async evt =>
Console.WriteLine($"Event: {evt.EventName}");
// Sync streaming handler (HTTP-over-WebSocket)
client.OnSyncRequest = async req =>
{
await req.Response.StartAsync(200, new() { ["Content-Type"] = ["text/plain"] });
await req.Response.WriteAsync(System.Text.Encoding.UTF8.GetBytes("Hello"));
await req.Response.CompleteAsync();
};
using var cts = new CancellationTokenSource();
Console.CancelKeyPress += (_, e) => { e.Cancel = true; cts.Cancel(); };
await client.RunForeverAsync(cts.Token);
Full configuration
| Property | Kubernetes annotation | Description |
|---|---|---|
FunctionName |
Deployment name | Unique name — must not match an existing K8s Deployment |
DependsOn |
SlimFaas/DependsOn |
Functions this one depends on |
SubscribeEvents |
SlimFaas/SubscribeEvents |
Events to subscribe to (each with optional visibility override) |
DefaultVisibility |
SlimFaas/DefaultVisibility |
FunctionVisibility.Public or FunctionVisibility.Private |
PathsStartWithVisibility |
SlimFaas/PathsStartWithVisibility |
Visibility per path prefix |
Configuration |
SlimFaas/Configuration |
Free-form JSON configuration |
ReplicasStartAsSoonAsOneFunctionRetrieveARequest |
SlimFaas/ReplicasStartAsSoonAsOneFunctionRetrieveARequest |
Global scale trigger |
NumberParallelRequest |
SlimFaas/NumberParallelRequest |
Max concurrent requests across all replicas |
NumberParallelRequestPerPod |
SlimFaas/NumberParallelRequestPerPod |
Max concurrent requests per replica |
DefaultTrust |
SlimFaas/DefaultTrust |
FunctionTrust.Trusted or FunctionTrust.Untrusted |
Connection options
| Property | Default | Description |
|---|---|---|
ReconnectDelay |
5.0 |
Seconds to wait before reconnecting after a disconnection |
PingInterval |
30.0 |
Keepalive ping interval in seconds, 0 disables pings |
ReceiveBufferSize |
65536 |
WebSocket receive buffer size in bytes |
var options = new SlimFaasClientOptions
{
ReconnectDelay = 5.0,
PingInterval = 30.0,
ReceiveBufferSize = 64 * 1024,
};
await using var client = new SlimFaasClient.SlimFaasClient(
new Uri("ws://slimfaas:5003/ws"), config, options);
Long-running requests (status 202)
Return 202 from the handler to acknowledge the request without completing it yet,
then call SendCallbackAsync when the work is done:
client.OnAsyncRequest = async req =>
{
_ = Task.Run(async () =>
{
await LongProcessAsync(req);
await client.SendCallbackAsync(req.ElementId, 200);
});
return 202; // "I'll handle it — will call back"
};
Dependency injection
// Register in your DI container (e.g. ASP.NET Core)
builder.Services.AddSingleton(sp =>
{
var logger = sp.GetRequiredService<ILogger<SlimFaasClient.SlimFaasClient>>();
var config = new SlimFaasClientConfig { FunctionName = "my-job" };
return new SlimFaasClient.SlimFaasClient(
new Uri("ws://slimfaas:5003/ws"), config, logger: logger);
});
// Access other services inside handlers via a scoped service provider
client.OnAsyncRequest = async req =>
{
using var scope = app.Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<IMyDatabase>();
await db.SaveAsync(req.Body);
return 200;
};
Important rules
FunctionNamemust not match an existing Kubernetes Deployment name. SlimFaas will reject the registration with aSlimFaasRegistrationException.All clients sharing the same
FunctionNamemust use the exact same configuration. Mismatches are rejected on connection.
Running the tests
dotnet test
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
-
net9.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
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 |
|---|---|---|
| 0.72.2 | 95 | 5/21/2026 |
| 0.72.1 | 87 | 5/19/2026 |
| 0.72.0 | 109 | 4/30/2026 |
| 0.71.3 | 95 | 4/28/2026 |
| 0.71.2 | 93 | 4/28/2026 |
| 0.71.1 | 101 | 4/15/2026 |
| 0.71.0 | 101 | 4/14/2026 |
| 0.70.2 | 99 | 4/14/2026 |
| 0.70.1 | 106 | 4/3/2026 |
| 0.70.0 | 104 | 4/2/2026 |
| 0.69.0 | 104 | 3/23/2026 |
| 0.68.0 | 99 | 3/23/2026 |
| 0.67.0 | 114 | 3/17/2026 |
| 0.66.5 | 102 | 3/12/2026 |