Path: redb-route/demo/redb.Route.Demo/Routes/ScopeDiagRoutes.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/redb.Route.Demo/Routes/ScopeDiagRoutes.cs
----
using Microsoft.Extensions.Logging;
using redb.Core.Models.Entities;
using redb.Route.Abstractions;
using redb.Route.Core;
using redb.Route.RedbCore.Extensions;
namespace redb.Route.Demo.Routes;
///
/// Scope diagnostics — parallel splitter connection tracking. Verifies that each parallel
/// scope gets its own and own DB connection lifecycle.
///
internal sealed class ScopeDiagRoutes : RouteBuilder
{
private readonly ILogger? _log;
public ScopeDiagRoutes(ILogger? log) => _log = log;
private static int _scopeDiagConcurrent;
private static int _scopeDiagPeakConcurrent;
private static int _scopeDiagTotalScopes;
protected override void Configure()
{
ConfigureScopeDiagRoute();
}
private void ConfigureScopeDiagRoute()
{
// Timer fires once after 10s, then every 60s (change period as needed)
From("timer://scope-diag?period=60000&delay=10000")
.RouteId("demo-scope-diag")
.AutoStart(false)
.Log("[SCOPE-DIAG] ▶ Starting parallel split: 50 items, maxDop=5")
// Reset counters
.Process(e =>
{
Interlocked.Exchange(ref _scopeDiagConcurrent, 0);
Interlocked.Exchange(ref _scopeDiagPeakConcurrent, 0);
Interlocked.Exchange(ref _scopeDiagTotalScopes, 0);
e.In.Body = Enumerable.Range(1, 50).Cast