Fluens 0.9.4

dotnet add package Fluens --version 0.9.4
                    
NuGet\Install-Package Fluens -Version 0.9.4
                    
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="Fluens" Version="0.9.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fluens" Version="0.9.4" />
                    
Directory.Packages.props
<PackageReference Include="Fluens" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Fluens --version 0.9.4
                    
#r "nuget: Fluens, 0.9.4"
                    
#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.
#:package Fluens@0.9.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Fluens&version=0.9.4
                    
Install as a Cake Addin
#tool nuget:?package=Fluens&version=0.9.4
                    
Install as a Cake Tool

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) plus Key / 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.Discovery registers it when DiscoveryOptions.ClusterId is non-blank; Fluens.Messaging.Redis requires 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: OperationCanceledException caused 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; the out T on the generic interface is inert, because where T : struct admits no implicit reference conversion and therefore no usable covariance.
  • IContext / Context — Execution context carrying ActivityId, TraceId, CorrelationId, MessageId, CausationId, UserId, and the nullable W3C TraceState (ADR 20260603000001 — paired with the traceparent embedded in ActivityId; consumed by Fluens.Messaging's MessagingActivitySource to reconstruct the full ActivityContext on 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); plus ClampPage(int? page) / ClampPageSize(int? pageSize) helpers. Both pass null through unclamped (meaning "not specified"); otherwise ClampPage floors the value at DefaultPage and ClampPageSize clamps it to [MinPageSize, MaxPageSize]. IPagingContext.Page is 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.IsLeader is true while this process holds the lease (always true without a store).
  • ILeadership.Term is 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.LeaderOnly is the declarative form for a hosted job: a worker built with base(logger, leadership) that overrides LeaderOnly to true runs 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 override LeaderOnly, or whose ILeadership is null, 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed