SlimFaasClient 0.84.9
dotnet add package SlimFaasClient --version 0.84.9
NuGet\Install-Package SlimFaasClient -Version 0.84.9
<PackageReference Include="SlimFaasClient" Version="0.84.9" />
<PackageVersion Include="SlimFaasClient" Version="0.84.9" />
<PackageReference Include="SlimFaasClient" />
paket add SlimFaasClient --version 0.84.9
#r "nuget: SlimFaasClient, 0.84.9"
#:package SlimFaasClient@0.84.9
#addin nuget:?package=SlimFaasClient&version=0.84.9
#tool nuget:?package=SlimFaasClient&version=0.84.9
<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);
Connection lifecycle
RunForeverAsync(ct) owns the connection until ct is cancelled:
- After a clean close by the server it reconnects immediately; after a network error or an unreachable server it waits
ReconnectDelayseconds and retries, forever. - It returns normally when
ctis cancelled, whether the cancellation happens while connected, while connecting or during the reconnect delay. It never surfaces anOperationCanceledExceptionfor its own token. - It throws
SlimFaasRegistrationExceptionwhen SlimFaas refuses the registration (name already used by a Kubernetes function, configuration mismatch): this is fatal and is not retried. IsConnectedistrueonly between a successful registration and the next disconnection;ConnectionIdisnulloutside that window.SendCallbackAsyncand the sync response methods throwInvalidOperationExceptionwhile disconnected.
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
The suite in tests/SlimFaasClient.Tests contains unit tests for the models and serialization, plus end-to-end protocol tests: SlimFaasClientWebSocketTests starts an in-process Kestrel WebSocket server (FakeSlimFaasServer) that speaks the SlimFaas protocol and drives a real SlimFaasClient through registration, async requests and callbacks, publish events, streamed sync requests, keepalive pings, malformed frames and reconnection. No running SlimFaas instance is needed.
| 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 (>= 10.0.11)
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.11)
-
net9.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.11)
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.84.9 | 0 | 9/14/2026 |
| 0.84.8 | 37 | 9/13/2026 |
| 0.84.7 | 38 | 9/13/2026 |
| 0.84.6 | 40 | 9/12/2026 |
| 0.84.5 | 43 | 9/11/2026 |
| 0.84.4 | 43 | 9/11/2026 |
| 0.84.3 | 44 | 9/10/2026 |
| 0.84.2 | 51 | 9/10/2026 |
| 0.84.1 | 44 | 9/10/2026 |
| 0.84.0 | 43 | 9/10/2026 |
| 0.83.0 | 52 | 9/9/2026 |
| 0.82.7 | 82 | 9/8/2026 |
| 0.82.6 | 70 | 9/8/2026 |
| 0.82.5 | 80 | 9/8/2026 |
| 0.82.4 | 91 | 9/2/2026 |
| 0.82.3 | 92 | 9/2/2026 |
| 0.82.2 | 82 | 9/1/2026 |
| 0.82.1 | 82 | 9/1/2026 |
| 0.82.0 | 90 | 8/28/2026 |
| 0.81.1 | 99 | 8/14/2026 |