Fluens 0.9.4
dotnet add package Fluens --version 0.9.4
NuGet\Install-Package Fluens -Version 0.9.4
<PackageReference Include="Fluens" Version="0.9.4" />
<PackageVersion Include="Fluens" Version="0.9.4" />
<PackageReference Include="Fluens" />
paket add Fluens --version 0.9.4
#r "nuget: Fluens, 0.9.4"
#:package Fluens@0.9.4
#addin nuget:?package=Fluens&version=0.9.4
#tool nuget:?package=Fluens&version=0.9.4
Fluens
Core builder infrastructure, options management, context and messaging abstractions, paging, background worker, and shared constants.
Installation
dotnet add package Fluens
Usage
Call AddFluens() to initialize the core builder infrastructure:
var fluensBuilder = builder.AddFluens();
This reads the Fluens:App configuration section and creates an IApplicationIdentity singleton:
{
"Fluens": {
"App": {
"Name": "MyApp",
"Version": "1.0.0",
"Instance": "instance-01",
"PublicUri": "https://myapp.example.com",
"UniqueId": 1
}
}
}
Key types:
IFluensBuilder— Central interface for configuring Fluens.IFluensModuleBuilder— Module-scoped builder carrying assembly, name, and schema context.IApplicationIdentity— Identity of one running application instance in the cluster (Name, Version, Instance, UniqueId, PublicUri) plusKey/UniqueKey, the canonical lowercase cluster identity and its instance-unique variant.IClusterIdentity— The cluster the application belongs to (ClusterId, never blank when registered).Fluens.Web.Discoveryregisters it whenDiscoveryOptions.ClusterIdis non-blank;Fluens.Messaging.Redisrequires it to name the broadcast channel.IOptionsManager— Configuration binding with validation (ConfigureRequired,Configure,GetRequired,Get).ValidatableOptions— Base class for options that support self-validation at startup.BackgroundWorker— Base class combining periodic timer with channel-based wake-up. Supports graceful shutdown:OperationCanceledExceptioncaused by the stopping token is silently handled (not logged as error).IDataProvider— Marker interface for cross-module read-only data providers.ITypedIdentifier/ITypedIdentifier<out T>— Strongly-typed identifier abstractions. The non-generic base allows working with identifiers without knowing the underlying value type; theout Ton the generic interface is inert, becausewhere T : structadmits no implicit reference conversion and therefore no usable covariance.IContext/Context— Execution context carrying ActivityId, TraceId, CorrelationId, MessageId, CausationId, UserId, and the nullable W3CTraceState(ADR 20260603000001 — paired with thetraceparentembedded inActivityId; consumed byFluens.Messaging'sMessagingActivitySourceto reconstruct the fullActivityContexton the consume hot-path).IContextProvider— Provides access to the current execution context.IModuleContextAccessor— Module execution context for CQRS boundary enforcement.IConsumedMessageContext— Context of a message being consumed from the inbox.MessagePriorities— Priority levels for inbox/outbox messages (Low, Normal, High).PagedResult<T>- Paged query result with Items, TotalPages, TotalItems, Page, PageSize.PagingDefaults- Static constants for pagination:DefaultPage(1),DefaultPageSize(20),MinPageSize(1),MaxPageSize(100); plusClampPage(int? page)/ClampPageSize(int? pageSize)helpers. Both passnullthrough unclamped (meaning "not specified"); otherwiseClampPagefloors the value atDefaultPageandClampPageSizeclamps it to[MinPageSize, MaxPageSize].IPagingContext.Pageis 1-based throughout the paging contract.Constants— Shared constants for CQRS query defaults and HTTP headers.TypeExtensions—GetModuleName()extension deriving module name from type namespace.ValueStopWatch— Zero-allocation, high-precision stopwatch struct.
Leadership
AddFluens() registers ILeadership, the role of this process, and its election loop as the first hosted service, so the default sequential host stop runs the election last and releases the lease after the other services stopped. The role is held through an ILeaderLease store: Fluens.Messaging.Redis provides one when the Redis broadcast is enabled, Fluens.Web.Discovery provides one in Consul otherwise, and with neither every process is leader.
ILeadership.IsLeaderistruewhile this process holds the lease (alwaystruewithout a store).ILeadership.Termis a token of the current term. It is cancelled synchronously the moment the role is lost or released, and it is never cancelled without a store.ILeadership.OnAcquired(callback)runs the callback on every acquisition. Dispose the result to unregister it.BackgroundWorker.LeaderOnlyis the declarative form for a hosted job: a worker built withbase(logger, leadership)that overridesLeaderOnlytotrueruns its pass only while this process is leader. The role is read on every tick, the pass receives a token linked to the stopping token and to the term it started in, and the end of the term cancels the pass without an error log. The worker is woken at once on every acquisition. A worker that does not overrideLeaderOnly, or whoseILeadershipisnull, runs every tick as before.
// A hosted job that runs on the leader only
public sealed class CleanupJob : BackgroundWorker
{
public CleanupJob(ILogger<CleanupJob> logger, ILeadership leadership)
: base(logger, leadership)
{
}
protected override TimeSpan IntervalTimeout => TimeSpan.FromHours(1);
protected override bool LeaderOnly => true;
protected override Task Run(CancellationToken stoppingToken) => CleanAsync(stoppingToken);
}
Lease timing comes from the store's options (Fluens:Messaging:Redis:Leader or Fluens:Web:Discovery:Leader). The Fluens.Leadership meter exports two instruments: leadership.active (observable gauge, 1 while leader, 0 while waiting) and leadership.takeovers (counter, +1 per acquisition through a store). Add Fluens.Leadership to ObservabilityOptions.AdditionalMeters to export them.
License
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- Fluens.Extensions (>= 0.9.4)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.13)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.13)
- Scrutor (>= 7.0.0)
NuGet packages (8)
Showing the top 5 NuGet packages that depend on Fluens:
| Package | Downloads |
|---|---|
|
Fluens.Web
ASP.NET Core base types for Fluens web libraries: Result-to-HTTP mapping, global exception handler, and paged responses. |
|
|
Fluens.Messaging
Inbox/outbox messaging pattern for modular applications. |
|
|
Fluens.Caching
HybridCache configuration helper for Fluens builder infrastructure. |
|
|
Fluens.Observability
OpenTelemetry tracing, metrics, logging, and Serilog structured logging integration with optional Seq sink. |
|
|
Fluens.Cqrs
CQRS pattern implementation with command/query dispatchers, handler interfaces, and logging/tracing decorators. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.9.4 | 437 | 11/30/2026 |
| 0.9.3 | 577 | 11/17/2026 |
| 0.9.2 | 411 | 10/21/2026 |
| 0.9.1 | 664 | 10/13/2026 |
| 0.9.0 | 282 | 10/13/2026 |
| 0.8.7 | 426 | 10/12/2026 |
| 0.8.6 | 284 | 10/12/2026 |
| 0.8.5 | 312 | 10/7/2026 |
| 0.8.4 | 271 | 10/6/2026 |
| 0.8.3 | 285 | 10/6/2026 |
| 0.8.2 | 343 | 10/5/2026 |
| 0.8.1 | 402 | 9/15/2026 |
| 0.8.0 | 290 | 9/15/2026 |
| 0.7.11 | 287 | 9/15/2026 |
| 0.7.10 | 292 | 9/13/2026 |
| 0.7.9 | 314 | 9/11/2026 |
| 0.7.8 | 320 | 9/10/2026 |
| 0.7.7 | 329 | 9/10/2026 |
| 0.7.6 | 372 | 7/1/2026 |
| 0.7.5 | 348 | 6/22/2026 |