Path: redb-route/demo/SerialNumbersDemo/SerialNumbers.Xml/Beans/SerialBeans.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/demo/SerialNumbersDemo/SerialNumbers.Xml/Beans/SerialBeans.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core; using redb.Route.Abstractions; using SerialNumbers.Core.Services; namespace SerialNumbers.Xml.Beans; /// /// The bridge between the markup and the module's services. A route calls /// bean:#name?method=X, and the bean invoker accepts (IExchange) or /// (IExchange, CancellationToken) - so every method here is that shape and hands the /// exchange to the service unchanged. The redb instance is the exchange's own, the same one /// ProcessWithRedb resolves in the C# spelling: one connection per exchange, enlisted in /// the transaction the route opened. /// public sealed class SerialRequestBeans { public Task Register(IExchange exchange, CancellationToken ct) => SerialRequestService.RegisterAsync(Redb(exchange), exchange, ct); public Task Allocate(IExchange exchange, CancellationToken ct) => SerialRequestService.AllocateAsync(Redb(exchange), exchange, ct); public Task Reject(IExchange exchange, CancellationToken ct) => SerialRequestService.RejectAsync(Redb(exchange), exchange, ct); public Task QueueResponse(IExchange exchange, CancellationToken ct) => SerialRequestService.QueueResponseAsync(Redb(exchange), exchange, ct); internal static IRedbService Redb(IExchange exchange) => exchange.ServiceProvider?.GetService() ?? throw new InvalidOperationException( "The exchange carries no IRedbService: the module must run in a host that registers redb (the Tsak worker does)."); } /// What the intake records when a file cannot be processed. public sealed class IntakeBeans { public Task RecordInvalid(IExchange exchange, CancellationToken ct) => IntakeRecorder.RecordInvalidAsync(SerialRequestBeans.Redb(exchange), exchange, ct); public Task RecordParked(IExchange exchange, CancellationToken ct) => IntakeRecorder.RecordParkedAsync(SerialRequestBeans.Redb(exchange), exchange, ct); }