MongoDB · Types · Routing, paging cookies and capabilities

ArxRouter

Definition

Namespace
ARX.SDK.Services
Package
ARX.SDK
C#
public sealed class ArxRouter<TService> : IArxRouter<TService>, IDisposable, IAsyncDisposable

The router Create{TService} makes. Disposing it disposes the services it made, not the ones it was given.

Properties

  • IReadOnlyCollection<string> RouteKeys { get; }

    Every declared route key.

Methods

  • static ArxRouter<TService> Create<TService>(Action<ArxRouterBuilder<TService>> configure, IServiceProvider? services = null)

    A router with the routes configure declares. Register it as a singleton, for example services.AddSingleton<IArxRouter<ArxMongoDbService>>(sp => ArxRouter.Create<ArxMongoDbService>(r => r.Route("acme", …), sp)).

    Parameter Type Description
    configureAction<ArxRouterBuilder<TService>>Declares the routes; at least one.
    servicesIServiceProvider?= nullOptional: passed to the route factories.
  • TService For(string routeKey)

    The service for this key. An unknown key is ARX1001 InvalidArgument (the message doesn't echo the key).

    Parameter Type Description
    routeKeystringThe key that picks the service: a tenant, a region, a shard.
  • bool TryFor(string routeKey, out TService service)

    The service for this key, or false when no route is declared for it.

    Parameter Type Description
    routeKeystringThe key that picks the service: a tenant, a region, a shard.
    serviceout TServiceThe service when the key has a route; otherwise the default.
  • void Dispose()

    Disposes the services the router made.

  • ValueTask DisposeAsync()

    Disposes the services the router made.