StellaOps.Router.Gateway

Router gateway core: the routing state of connected microservices, request routing and dispatch, and gateway rate limiting.

library
Component
Router
Licence
BUSL-1.1 (Router licence)
Target framework
net10.0
Latest release
1.0.1-20261117T070237Z

Install

dotnet add package StellaOps.Router.Gateway --version 1.0.1-20261117T070237Z

Namespaces

NamespaceTypes
StellaOps.Router.Gateway2
StellaOps.Router.Gateway.Authorization8
StellaOps.Router.Gateway.Configuration6
StellaOps.Router.Gateway.DependencyInjection1
StellaOps.Router.Gateway.Metrics5
StellaOps.Router.Gateway.Middleware17
StellaOps.Router.Gateway.OpenApi8
StellaOps.Router.Gateway.RateLimit21
StellaOps.Router.Gateway.Services10

namespace StellaOps.Router.Gateway

TypeKindDescription
ApplicationBuilderExtensionsclassExtension methods for configuring the router gateway middleware pipeline.
RouterHttpContextKeysclassWell-known HttpContext.Items keys for router pipeline.

class ApplicationBuilderExtensions

public static class ApplicationBuilderExtensions

Extension methods for configuring the router gateway middleware pipeline.

Members

MemberKindSummary
MapRouterOpenApi(IEndpointRouteBuilder)extension methodMaps OpenAPI endpoints to the application.
UseRateLimiting(IApplicationBuilder)extension methodAdds rate limiting middleware to the pipeline.
UseRouterGateway(IApplicationBuilder)extension methodAdds the router gateway middleware pipeline.
UseRouterGatewayCore(IApplicationBuilder)extension methodAdds the router gateway middleware pipeline without payload limiting.

extension method MapRouterOpenApi(IEndpointRouteBuilder) #

public static IEndpointRouteBuilder MapRouterOpenApi(this IEndpointRouteBuilder endpoints)

Maps OpenAPI endpoints to the application. Should be called before UseRouterGateway so OpenAPI requests are handled first.

Parameters

  • endpoints: The endpoint route builder.

Returns

The endpoint route builder for chaining.

extension method UseRateLimiting(IApplicationBuilder) #

public static IApplicationBuilder UseRateLimiting(this IApplicationBuilder app)

Adds rate limiting middleware to the pipeline.

Parameters

  • app: The application builder.

Returns

The application builder for chaining.

extension method UseRouterGateway(IApplicationBuilder) #

public static IApplicationBuilder UseRouterGateway(this IApplicationBuilder app)

Adds the router gateway middleware pipeline.

Parameters

  • app: The application builder.

Returns

The application builder for chaining.

extension method UseRouterGatewayCore(IApplicationBuilder) #

public static IApplicationBuilder UseRouterGatewayCore(this IApplicationBuilder app)

Adds the router gateway middleware pipeline without payload limiting.

Parameters

  • app: The application builder.

Returns

The application builder for chaining.

class RouterHttpContextKeys

public static class RouterHttpContextKeys

Well-known HttpContext.Items keys for router pipeline.

Members

MemberKindSummary
EndpointDescriptorconstantKey for the resolved EndpointDescriptor.
PathParametersconstantKey for path parameters extracted from route template matching.
PreResolvedEndpointconstantRequest-local resolution retained by SPA diversion.
RawRequestTargetconstantKey for the raw request target (IHttpRequestFeature.RawTarget: path plus query string with the wire percent-encoding intact) after Gateway route translation.
RouteDefaultTimeoutconstantKey for the route-level default timeout (TimeSpan) resolved from Gateway route table.
RouteTargetMicroserviceconstantKey for the route-level target microservice hint inferred from the gateway route entry.
RoutingDecisionconstantKey for the RoutingDecision.
TargetEndpointPathTemplateconstantKey for the resolved endpoint path template (EndpointDescriptor.Path).
TargetMicroserviceconstantKey for the resolved target microservice name (ServiceName).
TranslatedRequestPathconstantKey for the translated request path resolved from Gateway route translation.

constant EndpointDescriptor #

public const string EndpointDescriptor = "Stella.EndpointDescriptor"

Key for the resolved EndpointDescriptor.

constant PathParameters #

public const string PathParameters = "Stella.PathParameters"

Key for path parameters extracted from route template matching.

constant PreResolvedEndpoint #

public const string PreResolvedEndpoint = "Stella.Router.PreResolvedEndpoint"

Request-local resolution retained by SPA diversion.

constant RawRequestTarget #

public const string RawRequestTarget = "Stella.RawRequestTarget"

Key for the raw request target (IHttpRequestFeature.RawTarget: path plus query string with the wire percent-encoding intact) after Gateway route translation. Set only when a translation applied alongside RouterHttpContextKeys.TranslatedRequestPath; an untranslated request forwards the wire target verbatim without this key.

constant RouteDefaultTimeout #

public const string RouteDefaultTimeout = "Stella.RouteDefaultTimeout"

Key for the route-level default timeout (TimeSpan) resolved from Gateway route table.

constant RouteTargetMicroservice #

public const string RouteTargetMicroservice = "Stella.RouteTargetMicroservice"

Key for the route-level target microservice hint inferred from the gateway route entry.

constant RoutingDecision #

public const string RoutingDecision = "Stella.RoutingDecision"

Key for the RoutingDecision.

constant TargetEndpointPathTemplate #

public const string TargetEndpointPathTemplate = "Stella.TargetEndpointPathTemplate"

Key for the resolved endpoint path template (EndpointDescriptor.Path).

constant TargetMicroservice #

public const string TargetMicroservice = "Stella.TargetMicroservice"

Key for the resolved target microservice name (ServiceName).

constant TranslatedRequestPath #

public const string TranslatedRequestPath = "Stella.TranslatedRequestPath"

Key for the translated request path resolved from Gateway route translation.

namespace StellaOps.Router.Gateway.Authorization

TypeKindDescription
AuthorityConnectionOptionsclassConfiguration options for connecting to the Authority service.
AuthorizationMiddlewareclassMiddleware that enforces claims requirements for endpoints.
AuthorizationMiddlewareExtensionsclassExtension methods for registering the authorization middleware.
AuthorizationServiceCollectionExtensionsclassExtension methods for registering Authority integration services.
ClaimsOverrideChangedEventArgsclassEvent arguments for claims override changes.
EndpointKeystructKey for identifying an endpoint by service name, method, and path.
IAuthorityClaimsProviderinterfaceProvides claims overrides from the central Authority service.
IEffectiveClaimsStoreinterfaceStores and retrieves effective claims for endpoints.

class AuthorityConnectionOptions

public sealed class AuthorityConnectionOptions

Configuration options for connecting to the Authority service.

Members

MemberKindSummary
AuthorityConnectionOptions()constructorCreates an instance of AuthorityConnectionOptions.
HttpClientNameconstantName of the HttpClient the claims-overrides provider uses.
SectionNameconstantConfiguration section name.
AuthorityUrlpropertyGets or sets the Authority service URL.
EnabledpropertyGets or sets whether Authority integration is enabled.
RefreshIntervalpropertyGets or sets the interval at which to refresh claims from Authority.
StartupTimeoutpropertyGets or sets the startup timeout when waiting for Authority.
UseAuthorityPushNotificationspropertyGets or sets whether to use push notifications from Authority.
WaitForAuthorityOnStartuppropertyGets or sets whether to wait for Authority on startup.

constructor AuthorityConnectionOptions() #

public AuthorityConnectionOptions()

Creates an instance of AuthorityConnectionOptions.

constant HttpClientName #

public const string HttpClientName = "StellaOps.Router.Gateway.AuthorityClaims"

Name of the HttpClient the claims-overrides provider uses. A host that must authenticate the refresh (Authority requires authority:claims-overrides.read on GET /api/v1/claims/overrides) attaches its token handler to this name.

constant SectionName #

public const string SectionName = "Router:Authority"

Configuration section name.

property AuthorityUrl #

public string AuthorityUrl { get; set; }

Gets or sets the Authority service URL.

property Enabled #

public bool Enabled { get; set; }

Gets or sets whether Authority integration is enabled.

property RefreshInterval #

public TimeSpan RefreshInterval { get; set; }

Gets or sets the interval at which to refresh claims from Authority.

property StartupTimeout #

public TimeSpan StartupTimeout { get; set; }

Gets or sets the startup timeout when waiting for Authority.

property UseAuthorityPushNotifications #

public bool UseAuthorityPushNotifications { get; set; }

Gets or sets whether to use push notifications from Authority. If false, the gateway will poll at the refresh interval.

property WaitForAuthorityOnStartup #

public bool WaitForAuthorityOnStartup { get; set; }

Gets or sets whether to wait for Authority on startup. If true, the gateway will delay handling traffic until Authority is available.

class AuthorizationMiddleware

public sealed class AuthorizationMiddleware

Middleware that enforces claims requirements for endpoints.

Members

MemberKindSummary
AuthorizationMiddleware(RequestDelegate, IEffectiveClaimsStore, ILogger<AuthorizationMiddleware>)constructorInitializes a new instance of the AuthorizationMiddlewareclass.
InvokeAsync(HttpContext)methodInvokes the middleware.

constructor AuthorizationMiddleware(RequestDelegate, IEffectiveClaimsStore, ILogger<AuthorizationMiddleware>) #

public AuthorizationMiddleware(RequestDelegate next, IEffectiveClaimsStore claimsStore, ILogger<AuthorizationMiddleware> logger)

Initializes a new instance of the AuthorizationMiddlewareclass.

method InvokeAsync(HttpContext) #

public Task InvokeAsync(HttpContext context)

Invokes the middleware.

class AuthorizationMiddlewareExtensions

public static class AuthorizationMiddlewareExtensions

Extension methods for registering the authorization middleware.

Members

MemberKindSummary
UseClaimsAuthorization(IApplicationBuilder)extension methodAdds the claims authorization middleware to the pipeline.

extension method UseClaimsAuthorization(IApplicationBuilder) #

public static IApplicationBuilder UseClaimsAuthorization(this IApplicationBuilder app)

Adds the claims authorization middleware to the pipeline.

Parameters

  • app: The application builder.

Returns

The application builder for chaining.

class AuthorizationServiceCollectionExtensions

public static class AuthorizationServiceCollectionExtensions

Extension methods for registering Authority integration services.

Members

MemberKindSummary
AddAuthorityIntegration(IServiceCollection, Action<AuthorityConnectionOptions>)extension methodAdds Authority integration services with custom options.
AddAuthorityIntegration(IServiceCollection, IConfiguration)extension methodAdds Authority integration services to the service collection.
AddNoOpAuthorityIntegration(IServiceCollection)extension methodAdds a no-op Authority integration (no external Authority).

extension method AddAuthorityIntegration(IServiceCollection, Action<AuthorityConnectionOptions>) #

public static IServiceCollection AddAuthorityIntegration(this IServiceCollection services, Action<AuthorityConnectionOptions>? configure = null)

Adds Authority integration services with custom options.

Parameters

  • services: The service collection.
  • configure: Action to configure Authority options.

Returns

The service collection for chaining.

extension method AddAuthorityIntegration(IServiceCollection, IConfiguration) #

public static IServiceCollection AddAuthorityIntegration(this IServiceCollection services, IConfiguration configuration)

Adds Authority integration services to the service collection.

Parameters

  • services: The service collection.
  • configuration: The configuration.

Returns

The service collection for chaining.

extension method AddNoOpAuthorityIntegration(IServiceCollection) #

public static IServiceCollection AddNoOpAuthorityIntegration(this IServiceCollection services)

Adds a no-op Authority integration (no external Authority). Claims are only from microservices.

Parameters

  • services: The service collection.

Returns

The service collection for chaining.

class ClaimsOverrideChangedEventArgs

public sealed class ClaimsOverrideChangedEventArgs : EventArgs

Event arguments for claims override changes.

Members

MemberKindSummary
ClaimsOverrideChangedEventArgs()constructorCreates an instance of ClaimsOverrideChangedEventArgs.
OverridespropertyGets the updated claims overrides.

constructor ClaimsOverrideChangedEventArgs() #

public ClaimsOverrideChangedEventArgs()

Creates an instance of ClaimsOverrideChangedEventArgs.

property Overrides #

public IReadOnlyDictionary<EndpointKey, IReadOnlyList<ClaimRequirement>> Overrides { get; init; }

Gets the updated claims overrides.

struct EndpointKey

public readonly struct EndpointKey : IEquatable<EndpointKey>

Key for identifying an endpoint by service name, method, and path.

Parameters

  • ServiceName: The name of the service.
  • Method: The HTTP method.
  • Path: The path template.

Members

MemberKindSummary
EndpointKey(string, string, string)constructorKey for identifying an endpoint by service name, method, and path.
MethodpropertyThe HTTP method.
PathpropertyThe path template.
ServiceNamepropertyThe name of the service.
Create(string, string, string)methodCreates an endpoint key with normalized values.
ToString()methodSee ValueType.ToString().

constructor EndpointKey(string, string, string) #

public EndpointKey(string ServiceName, string Method, string Path)

Key for identifying an endpoint by service name, method, and path.

Parameters

  • ServiceName: The name of the service.
  • Method: The HTTP method.
  • Path: The path template.

property Method #

public string Method { get; init; }

The HTTP method.

property Path #

public string Path { get; init; }

The path template.

property ServiceName #

public string ServiceName { get; init; }

The name of the service.

method Create(string, string, string) #

public static EndpointKey Create(string serviceName, string method, string path)

Creates an endpoint key with normalized values.

method ToString() #

public override string ToString()

See ValueType.ToString().

interface IAuthorityClaimsProvider

public interface IAuthorityClaimsProvider

Provides claims overrides from the central Authority service.

Members

MemberKindSummary
IsAvailablepropertyGets a value indicating whether the Authority is currently available.
OverridesChangedeventOccurs when claims overrides change.
GetOverridesAsync(CancellationToken)methodGets all claims overrides from Authority.

property IsAvailable #

bool IsAvailable { get; }

Gets a value indicating whether the Authority is currently available.

event OverridesChanged #

event EventHandler<ClaimsOverrideChangedEventArgs>? OverridesChanged

Occurs when claims overrides change.

method GetOverridesAsync(CancellationToken) #

Task<IReadOnlyDictionary<EndpointKey, IReadOnlyList<ClaimRequirement>>> GetOverridesAsync(CancellationToken cancellationToken)

Gets all claims overrides from Authority.

Parameters

  • cancellationToken: The cancellation token.

Returns

A dictionary of endpoint keys to claim requirements.

interface IEffectiveClaimsStore

public interface IEffectiveClaimsStore

Stores and retrieves effective claims for endpoints. Handles merging of microservice defaults with Authority overrides.

Members

MemberKindSummary
GetEffectiveClaims(string, string, string, string)methodGets the effective claims for an endpoint of one version of a service.
RemoveService(string, string)methodRemoves the claims of one version of a service.
UpdateFromAuthority(IReadOnlyDictionary<EndpointKey, IReadOnlyList<ClaimRequirement>>)methodUpdates claims from Authority overrides.
UpdateFromMicroservice(string, string, IReadOnlyList<EndpointDescriptor>)methodUpdates the claims of one version of a service from its HELLO message; other versions keep theirs.

method GetEffectiveClaims(string, string, string, string) #

IReadOnlyList<ClaimRequirement> GetEffectiveClaims(string serviceName, string version, string method, string path)

Gets the effective claims for an endpoint of one version of a service. Authority overrides (which name no version) take precedence over the version’s own claims.

Parameters

  • serviceName: The service name.
  • version: The service version whose claims apply.
  • method: The HTTP method.
  • path: The path template.

Returns

The effective claims for the endpoint.

method RemoveService(string, string) #

void RemoveService(string serviceName, string version)

Removes the claims of one version of a service. Called when the last instance of that version disconnects.

Parameters

  • serviceName: The service name.
  • version: The service version.

method UpdateFromAuthority(IReadOnlyDictionary<EndpointKey, IReadOnlyList<ClaimRequirement>>) #

void UpdateFromAuthority(IReadOnlyDictionary<EndpointKey, IReadOnlyList<ClaimRequirement>> overrides)

Updates claims from Authority overrides.

Parameters

  • overrides: The Authority claims overrides.

method UpdateFromMicroservice(string, string, IReadOnlyList<EndpointDescriptor>) #

void UpdateFromMicroservice(string serviceName, string version, IReadOnlyList<EndpointDescriptor> endpoints)

Updates the claims of one version of a service from its HELLO message; other versions keep theirs.

Parameters

  • serviceName: The service name.
  • version: The version of the instance that sent the HELLO.
  • endpoints: The endpoint descriptors with claims.

namespace StellaOps.Router.Gateway.Configuration

TypeKindDescription
HealthOptionsclassConfiguration options for health monitoring.
RouterNodeConfigclassStatic configuration for a router gateway node.
RoutingOptionsclassOptions for routing behavior.
StellaOpsRouteclassA static route of the gateway: a path and what the gateway does with the requests that match it.
StellaOpsRouteTypeenumWhat a static route does with a matching request.
TieBreakerModeenumTie-breaker mode for routing when multiple instances have equal priority.

class HealthOptions

public sealed class HealthOptions

Configuration options for health monitoring.

Members

MemberKindSummary
HealthOptions()constructorCreates an instance of HealthOptions.
SectionNameconstantGets the configuration section name.
CheckIntervalpropertyGets or sets the interval at which to check for stale connections.
DegradedThresholdpropertyGets or sets the threshold after which a connection is considered degraded.
PingHistorySizepropertyGets or sets the number of ping measurements to keep for averaging.
StaleThresholdpropertyGets or sets the threshold after which a connection is considered stale (no heartbeat).

constructor HealthOptions() #

public HealthOptions()

Creates an instance of HealthOptions.

constant SectionName #

public const string SectionName = "Router:Health"

Gets the configuration section name.

property CheckInterval #

public TimeSpan CheckInterval { get; set; }

Gets or sets the interval at which to check for stale connections. Default: 15 seconds.

property DegradedThreshold #

public TimeSpan DegradedThreshold { get; set; }

Gets or sets the threshold after which a connection is considered degraded. Should be at least 2x the service heartbeat interval (the SDK default is 10 seconds). Default: 90 seconds.

property PingHistorySize #

public int PingHistorySize { get; set; }

Gets or sets the number of ping measurements to keep for averaging. Default: 10.

property StaleThreshold #

public TimeSpan StaleThreshold { get; set; }

Gets or sets the threshold after which a connection is considered stale (no heartbeat). Should be at least 3x the service heartbeat interval (the SDK default is 10 seconds). Default: 135 seconds.

class RouterNodeConfig

public sealed class RouterNodeConfig

Static configuration for a router gateway node.

Members

MemberKindSummary
RouterNodeConfig()constructorCreates an instance of RouterNodeConfig.
LegacySectionNameconstantThe alternative configuration section name, read only when the RouterNodeConfig.SectionNamesection does not exist.
SectionNameconstantConfiguration section name for binding.
EnvironmentpropertyGets or sets the environment name (e.g., “prod”, “staging”, “dev”).
NeighborRegionspropertyGets or sets the neighbor regions for fallback routing, in order of preference.
NodeIdpropertyGets or sets the unique identifier for this gateway node (e.g., “gw-eu1-01”).
RegionpropertyGets or sets the region where this gateway is deployed (e.g., “eu1”).
Validate()methodValidates the configuration.

constructor RouterNodeConfig() #

public RouterNodeConfig()

Creates an instance of RouterNodeConfig.

constant LegacySectionName #

public const string LegacySectionName = "Router:Node"

The alternative configuration section name, read only when the RouterNodeConfig.SectionNamesection does not exist.

constant SectionName #

public const string SectionName = "GatewayNode"

Configuration section name for binding.

property Environment #

public string Environment { get; set; }

Gets or sets the environment name (e.g., “prod”, “staging”, “dev”).

property NeighborRegions #

public List<string> NeighborRegions { get; set; }

Gets or sets the neighbor regions for fallback routing, in order of preference.

property NodeId #

public string NodeId { get; set; }

Gets or sets the unique identifier for this gateway node (e.g., “gw-eu1-01”).

property Region #

public string Region { get; set; }

Gets or sets the region where this gateway is deployed (e.g., “eu1”). Routing decisions use this value; it is never derived from headers or URLs.

method Validate() #

public void Validate()

Validates the configuration.

Exceptions

  • InvalidOperationException: Thrown when configuration is invalid.

class RoutingOptions

public sealed class RoutingOptions

Options for routing behavior.

Members

MemberKindSummary
RoutingOptions()constructorCreates an instance of RoutingOptions.
SectionNameconstantConfiguration section name for binding.
AllowDegradedInstancespropertyGets or sets whether to allow routing to degraded instances when no healthy instances are available.
DefaultVersionpropertyGets or sets the default version to use when no version is specified in the request.
GlobalTimeoutCapMspropertyGets or sets the global timeout cap in milliseconds.
MaxWeightOverridepropertyGets or sets the maximum accepted runtime routing weight override.
PingToleranceMspropertyGets or sets the ping tolerance in milliseconds for considering instances “tied”.
PreferLocalRegionpropertyGets or sets whether to prefer local region instances over neighbor regions.
RoutingTimeoutMspropertyGets or sets the gateway route default timeout in milliseconds.
TieBreakerpropertyGets or sets the tie-breaker mode when multiple instances have equal priority.
WeightOverridespropertyGets or sets gateway-side routing weight overrides.

constructor RoutingOptions() #

public RoutingOptions()

Creates an instance of RoutingOptions.

constant SectionName #

public const string SectionName = "Router:Routing"

Configuration section name for binding.

property AllowDegradedInstances #

public bool AllowDegradedInstances { get; set; }

Gets or sets whether to allow routing to degraded instances when no healthy instances are available.

property DefaultVersion #

public string? DefaultVersion { get; set; }

Gets or sets the default version to use when no version is specified in the request. If null, requests without version specification will match any available version.

property GlobalTimeoutCapMs #

public int GlobalTimeoutCapMs { get; set; }

Gets or sets the global timeout cap in milliseconds. Effective request timeout cannot exceed this value.

property MaxWeightOverride #

public int MaxWeightOverride { get; set; }

Gets or sets the maximum accepted runtime routing weight override.

property PingToleranceMs #

public double PingToleranceMs { get; set; }

Gets or sets the ping tolerance in milliseconds for considering instances “tied”. Instances within this tolerance of each other are considered to have equal latency.

property PreferLocalRegion #

public bool PreferLocalRegion { get; set; }

Gets or sets whether to prefer local region instances over neighbor regions.

property RoutingTimeoutMs #

public int RoutingTimeoutMs { get; set; }

Gets or sets the gateway route default timeout in milliseconds.

property TieBreaker #

public TieBreakerMode TieBreaker { get; set; }

Gets or sets the tie-breaker mode when multiple instances have equal priority.

property WeightOverrides #

public Dictionary<string, int> WeightOverrides { get; set; }

Gets or sets gateway-side routing weight overrides. Keys are service/version/instanceId for one instance, or service/version for a version-wide override.

class StellaOpsRoute

public sealed class StellaOpsRoute

A static route of the gateway: a path and what the gateway does with the requests that match it.

Members

MemberKindSummary
StellaOpsRoute()constructorCreates an instance of StellaOpsRoute.
DefaultTimeoutpropertyOptional route-level default timeout (for example “15s”, “2m”).
HeaderspropertyHeaders added to the forwarded request.
IsRegexpropertyWhether StellaOpsRoute.Pathis a regular expression.
PathpropertyThe path the route matches: a path and the paths below it, or a regular expression when StellaOpsRoute.IsRegexis set.
PreserveAuthHeaderspropertyWhen true, the gateway preserves Authorization and DPoP headers instead of stripping them.
TranslatesTopropertyThe target: an HTTP or HTTPS URL for a proxy route, a ws or wss URL for a WebSocket route, a directory for a static files route, and a file for a static file route or an error page.
TypepropertyWhat the route does with a matching request.

constructor StellaOpsRoute() #

public StellaOpsRoute()

Creates an instance of StellaOpsRoute.

property DefaultTimeout #

public string? DefaultTimeout { get; set; }

Optional route-level default timeout (for example “15s”, “2m”). Applied when endpoint metadata does not provide a timeout.

property Headers #

public Dictionary<string, string> Headers { get; set; }

Headers added to the forwarded request.

property IsRegex #

public bool IsRegex { get; set; }

Whether StellaOpsRoute.Pathis a regular expression.

property Path #

public string Path { get; set; }

The path the route matches: a path and the paths below it, or a regular expression when StellaOpsRoute.IsRegexis set.

property PreserveAuthHeaders #

public bool PreserveAuthHeaders { get; set; }

When true, the gateway preserves Authorization and DPoP headers instead of stripping them. Use for upstream services that perform their own JWT validation.

property TranslatesTo #

public string? TranslatesTo { get; set; }

The target: an HTTP or HTTPS URL for a proxy route, a ws or wss URL for a WebSocket route, a directory for a static files route, and a file for a static file route or an error page.

property Type #

public StellaOpsRouteType Type { get; set; }

What the route does with a matching request.

enum StellaOpsRouteType

public enum StellaOpsRouteType

What a static route does with a matching request.

ValueDescription
Microservice = 0The request goes to a microservice through the Router.
ReverseProxy = 1The request is proxied to the StellaOpsRoute.TranslatesToaddress.
StaticFiles = 2The request is served from a directory of static files.
StaticFile = 3The request is served with one static file.
WebSocket = 4The request is a WebSocket proxied to the StellaOpsRoute.TranslatesToaddress.
NotFoundPage = 5The page served for a request that no route matches.
ServerErrorPage = 6The page served for a server error.

enum TieBreakerMode

public enum TieBreakerMode

Tie-breaker mode for routing when multiple instances have equal priority.

ValueDescription
Random = 0Select randomly among tied instances.
RoundRobin = 1Rotate through tied instances in order.

namespace StellaOps.Router.Gateway.DependencyInjection

TypeKindDescription
RouterServiceCollectionExtensionsclassExtension methods for registering router gateway services.

class RouterServiceCollectionExtensions

public static class RouterServiceCollectionExtensions

Extension methods for registering router gateway services.

Members

MemberKindSummary
AddRouterGateway(IServiceCollection, Action<RouterNodeConfig>, Action<RoutingOptions>)extension methodAdds router gateway services with custom options.
AddRouterGateway(IServiceCollection, IConfiguration)extension methodAdds router gateway services to the service collection.
AddRouterGatewayCore(IServiceCollection)extension methodAdds router gateway services with minimal defaults.
AddRouterGatewayLocalHarness(IServiceCollection, IHostEnvironment)extension methodAdds the gateway lifecycle services required by an explicit process-local transport harness.

extension method AddRouterGateway(IServiceCollection, Action<RouterNodeConfig>, Action<RoutingOptions>) #

public static IServiceCollection AddRouterGateway(this IServiceCollection services, Action<RouterNodeConfig>? configureNode = null, Action<RoutingOptions>? configureRouting = null)

Adds router gateway services with custom options.

Parameters

  • services: The service collection.
  • configureNode: Action to configure router node options.
  • configureRouting: Action to configure routing options.

Returns

The service collection for chaining.

extension method AddRouterGateway(IServiceCollection, IConfiguration) #

public static IServiceCollection AddRouterGateway(this IServiceCollection services, IConfiguration configuration)

Adds router gateway services to the service collection.

Parameters

  • services: The service collection.
  • configuration: The configuration.

Returns

The service collection for chaining.

extension method AddRouterGatewayCore(IServiceCollection) #

public static IServiceCollection AddRouterGatewayCore(this IServiceCollection services)

Adds router gateway services with minimal defaults.

Parameters

  • services: The service collection.

Returns

The service collection for chaining.

extension method AddRouterGatewayLocalHarness(IServiceCollection, IHostEnvironment) #

public static IServiceCollection AddRouterGatewayLocalHarness(this IServiceCollection services, IHostEnvironment environment)

Adds the gateway lifecycle services required by an explicit process-local transport harness.

Parameters

  • services: The service collection.
  • environment: The host environment used to gate local harness registration.

Returns

The service collection for chaining.

Exceptions

  • InvalidOperationException: Thrown when the host environment is not Development, Testing, or Local.

namespace StellaOps.Router.Gateway.Metrics

TypeKindDescription
IRouterGatewayMetricsinterfaceRecords the routed requests and returns their counts and durations.
RouterGatewayMetricsclassRecords the routed requests on the meter RouterGatewayMetrics.MeterNameand keeps their totals for the Prometheus text of the gateway.
RouterRequestDurationBucketrecordOne cumulative histogram bucket.
RouterRequestDurationMetricSamplerecordThe duration histogram of the requests of one service version and instance.
RouterRequestMetricSamplerecordThe number of requests of one service version and instance with one status class.

interface IRouterGatewayMetrics

public interface IRouterGatewayMetrics

Records the routed requests and returns their counts and durations.

Members

MemberKindSummary
GetRequestDurations()methodReturns the request duration histograms so far, by service, version and instance.
GetRequestTotals()methodReturns the request counts so far, by service, version, instance and status class.
RecordRequest(RoutingDecision, int, TimeSpan)methodRecords one routed request.

method GetRequestDurations() #

IReadOnlyList<RouterRequestDurationMetricSample> GetRequestDurations()

Returns the request duration histograms so far, by service, version and instance.

Returns

The duration histograms.

method GetRequestTotals() #

IReadOnlyList<RouterRequestMetricSample> GetRequestTotals()

Returns the request counts so far, by service, version, instance and status class.

Returns

The request counts.

method RecordRequest(RoutingDecision, int, TimeSpan) #

void RecordRequest(RoutingDecision decision, int statusCode, TimeSpan duration)

Records one routed request.

Parameters

  • decision: The routing decision: service, version and instance.
  • statusCode: The response status code.
  • duration: How long the request took.

class RouterGatewayMetrics

public sealed class RouterGatewayMetrics : IRouterGatewayMetrics, IDisposable

Records the routed requests on the meter RouterGatewayMetrics.MeterNameand keeps their totals for the Prometheus text of the gateway.

Members

MemberKindSummary
RouterGatewayMetrics()constructorCreates an instance of RouterGatewayMetrics.
MeterNameconstantThe name of the meter that carries the request counter and the duration histogram.
Dispose()methodDisposes the meter.
GetRequestDurations()methodReturns the request duration histograms so far, by service, version and instance.
GetRequestTotals()methodReturns the request counts so far, by service, version, instance and status class.
RecordRequest(RoutingDecision, int, TimeSpan)methodRecords one routed request.

constructor RouterGatewayMetrics() #

public RouterGatewayMetrics()

Creates an instance of RouterGatewayMetrics.

constant MeterName #

public const string MeterName = "StellaOps.Router.Gateway"

The name of the meter that carries the request counter and the duration histogram.

method Dispose() #

public void Dispose()

Disposes the meter.

method GetRequestDurations() #

public IReadOnlyList<RouterRequestDurationMetricSample> GetRequestDurations()

Returns the request duration histograms so far, by service, version and instance.

Returns

The duration histograms.

method GetRequestTotals() #

public IReadOnlyList<RouterRequestMetricSample> GetRequestTotals()

Returns the request counts so far, by service, version, instance and status class.

Returns

The request counts.

method RecordRequest(RoutingDecision, int, TimeSpan) #

public void RecordRequest(RoutingDecision decision, int statusCode, TimeSpan duration)

Records one routed request.

Parameters

  • decision: The routing decision: service, version and instance.
  • statusCode: The response status code.
  • duration: How long the request took.

record RouterRequestDurationBucket

public sealed record RouterRequestDurationBucket

One cumulative histogram bucket.

Parameters

  • UpperBound: The upper bound of the bucket, in seconds.
  • Count: The requests at most that long.

Members

MemberKindSummary
RouterRequestDurationBucket(string, long)constructorOne cumulative histogram bucket.
CountpropertyThe requests at most that long.
UpperBoundpropertyThe upper bound of the bucket, in seconds.

constructor RouterRequestDurationBucket(string, long) #

public RouterRequestDurationBucket(string UpperBound, long Count)

One cumulative histogram bucket.

Parameters

  • UpperBound: The upper bound of the bucket, in seconds.
  • Count: The requests at most that long.

property Count #

public long Count { get; init; }

The requests at most that long.

property UpperBound #

public string UpperBound { get; init; }

The upper bound of the bucket, in seconds.

record RouterRequestDurationMetricSample

public sealed record RouterRequestDurationMetricSample

The duration histogram of the requests of one service version and instance.

Parameters

  • Service: The service.
  • Version: The service version.
  • InstanceId: The instance.
  • Buckets: The cumulative bucket counts.
  • Count: The number of requests.
  • SumSeconds: The sum of the request durations, in seconds.

Members

MemberKindSummary
RouterRequestDurationMetricSample(string, string, string, IReadOnlyList<RouterRequestDurationBucket>, long, double)constructorThe duration histogram of the requests of one service version and instance.
BucketspropertyThe cumulative bucket counts.
CountpropertyThe number of requests.
InstanceIdpropertyThe instance.
ServicepropertyThe service.
SumSecondspropertyThe sum of the request durations, in seconds.
VersionpropertyThe service version.

constructor RouterRequestDurationMetricSample(string, string, string, IReadOnlyList<RouterRequestDurationBucket>, long, double) #

public RouterRequestDurationMetricSample(string Service, string Version, string InstanceId, IReadOnlyList<RouterRequestDurationBucket> Buckets, long Count, double SumSeconds)

The duration histogram of the requests of one service version and instance.

Parameters

  • Service: The service.
  • Version: The service version.
  • InstanceId: The instance.
  • Buckets: The cumulative bucket counts.
  • Count: The number of requests.
  • SumSeconds: The sum of the request durations, in seconds.

property Buckets #

public IReadOnlyList<RouterRequestDurationBucket> Buckets { get; init; }

The cumulative bucket counts.

property Count #

public long Count { get; init; }

The number of requests.

property InstanceId #

public string InstanceId { get; init; }

The instance.

property Service #

public string Service { get; init; }

The service.

property SumSeconds #

public double SumSeconds { get; init; }

The sum of the request durations, in seconds.

property Version #

public string Version { get; init; }

The service version.

record RouterRequestMetricSample

public sealed record RouterRequestMetricSample

The number of requests of one service version and instance with one status class.

Parameters

  • Service: The service.
  • Version: The service version.
  • InstanceId: The instance.
  • StatusClass: The status class, for example 2xx.
  • Count: The number of requests.

Members

MemberKindSummary
RouterRequestMetricSample(string, string, string, string, long)constructorThe number of requests of one service version and instance with one status class.
CountpropertyThe number of requests.
InstanceIdpropertyThe instance.
ServicepropertyThe service.
StatusClasspropertyThe status class, for example 2xx.
VersionpropertyThe service version.

constructor RouterRequestMetricSample(string, string, string, string, long) #

public RouterRequestMetricSample(string Service, string Version, string InstanceId, string StatusClass, long Count)

The number of requests of one service version and instance with one status class.

Parameters

  • Service: The service.
  • Version: The service version.
  • InstanceId: The instance.
  • StatusClass: The status class, for example 2xx.
  • Count: The number of requests.

property Count #

public long Count { get; init; }

The number of requests.

property InstanceId #

public string InstanceId { get; init; }

The instance.

property Service #

public string Service { get; init; }

The service.

property StatusClass #

public string StatusClass { get; init; }

The status class, for example 2xx.

property Version #

public string Version { get; init; }

The service version.

namespace StellaOps.Router.Gateway.Middleware

TypeKindDescription
AttestationCheckResultrecordResult of an attestation check.
AttestationMiddlewareclassMiddleware that checks for attestations on artifact requests.
AttestationMiddlewareExtensionsclassExtension methods for attestation middleware.
AttestationMiddlewareOptionsclassConfiguration for attestation middleware.
ByteCountingStreamclassA stream wrapper that counts bytes read and enforces a limit.
DefaultAttestationLookupServiceclassDefault implementation of attestation lookup service.
EndpointResolutionMiddlewareclassResolves incoming HTTP requests to endpoint descriptors using the routing state.
GlobalErrorHandlerMiddlewareclassCatches unhandled exceptions and returns a structured JSON error response.
IAttestationLookupServiceinterfaceService for looking up attestations.
IPayloadTrackerinterfaceTracks payload bytes across requests, connections, and globally.
PayloadLimitExceededExceptionclassException thrown when a payload limit is exceeded during streaming.
PayloadLimitsMiddlewareclassMiddleware that enforces payload limits per-request, per-connection, and aggregate.
PayloadTrackerclassDefault implementation of IPayloadTracker.
RequestLoggingMiddlewareclassLogs basic request/response information for gateway requests.
RouterErrorWriterclassThe gateway’s single writer for error responses.
RoutingDecisionMiddlewareclassMakes routing decisions for resolved endpoints.
TransportDispatchMiddlewareclassDispatches HTTP requests to microservices via the transport layer.

record AttestationCheckResult

public sealed record AttestationCheckResult

Result of an attestation check.

Members

MemberKindSummary
AttestationCheckResult()constructorCreates an instance of AttestationCheckResult.
AllPresentpropertyWhether all required attestations are present.
CheckedAtpropertyTimestamp of the check.
DigestpropertyArtifact digest that was checked.
MissingTypespropertyList of missing attestation types.
PresentTypespropertyList of present attestation types.
RekorLogIndexpropertyRekor log index if verified.

constructor AttestationCheckResult() #

public AttestationCheckResult()

Creates an instance of AttestationCheckResult.

property AllPresent #

public bool AllPresent { get; init; }

Whether all required attestations are present.

property CheckedAt #

public DateTimeOffset CheckedAt { get; init; }

Timestamp of the check.

property Digest #

public required string Digest { get; init; }

Artifact digest that was checked.

property MissingTypes #

public List<string> MissingTypes { get; init; }

List of missing attestation types.

property PresentTypes #

public List<string> PresentTypes { get; init; }

List of present attestation types.

property RekorLogIndex #

public long? RekorLogIndex { get; init; }

Rekor log index if verified.

class AttestationMiddleware

public sealed class AttestationMiddleware

Middleware that checks for attestations on artifact requests.

Members

MemberKindSummary
AttestationMiddleware(RequestDelegate, IAttestationLookupService, IMemoryCache, IOptions<AttestationMiddlewareOptions>, ILogger<AttestationMiddleware>)constructorCreates the middleware.
InvokeAsync(HttpContext)methodChecks the required attestations of an artifact request; a request whose artifact misses one can be refused with 403, depending on the options.

constructor AttestationMiddleware(RequestDelegate, IAttestationLookupService, IMemoryCache, IOptions<AttestationMiddlewareOptions>, ILogger<AttestationMiddleware>) #

public AttestationMiddleware(RequestDelegate next, IAttestationLookupService lookupService, IMemoryCache cache, IOptions<AttestationMiddlewareOptions> options, ILogger<AttestationMiddleware> logger)

Creates the middleware.

Parameters

  • next: The next middleware.
  • lookupService: Looks up the attestations of an artifact.
  • cache: Caches the lookups.
  • options: The attestation checks.
  • logger: Receives the diagnostics.

method InvokeAsync(HttpContext) #

public Task InvokeAsync(HttpContext context)

Checks the required attestations of an artifact request; a request whose artifact misses one can be refused with 403, depending on the options.

Parameters

  • context: The HTTP context.

Returns

A task that completes when the request is handled.

class AttestationMiddlewareExtensions

public static class AttestationMiddlewareExtensions

Extension methods for attestation middleware.

Members

MemberKindSummary
UseAttestationMiddleware(IApplicationBuilder)extension methodAdds attestation middleware to the pipeline.

extension method UseAttestationMiddleware(IApplicationBuilder) #

public static IApplicationBuilder UseAttestationMiddleware(this IApplicationBuilder app)

Adds attestation middleware to the pipeline.

class AttestationMiddlewareOptions

public sealed class AttestationMiddlewareOptions

Configuration for attestation middleware.

Members

MemberKindSummary
AttestationMiddlewareOptions()constructorCreates an instance of AttestationMiddlewareOptions.
CacheResultspropertyWhether to cache attestation check results.
CacheTtlSecondspropertyCache TTL in seconds.
EnabledpropertyWhether attestation checking is enabled.
ModepropertyOperation mode: “audit” (log only) or “enforce” (block if missing).
RekorUrlpropertyRekor URL for transparency log verification.
RequireTypespropertyRequired attestation types (e.g., “sbom”, “vex”).
SkipPathspropertySkip attestation check for these paths (regex patterns).

constructor AttestationMiddlewareOptions() #

public AttestationMiddlewareOptions()

Creates an instance of AttestationMiddlewareOptions.

property CacheResults #

public bool CacheResults { get; set; }

Whether to cache attestation check results.

property CacheTtlSeconds #

public int CacheTtlSeconds { get; set; }

Cache TTL in seconds.

property Enabled #

public bool Enabled { get; set; }

Whether attestation checking is enabled.

property Mode #

public string Mode { get; set; }

Operation mode: “audit” (log only) or “enforce” (block if missing).

property RekorUrl #

public string? RekorUrl { get; set; }

Rekor URL for transparency log verification.

property RequireTypes #

public List<string> RequireTypes { get; set; }

Required attestation types (e.g., “sbom”, “vex”).

property SkipPaths #

public List<string> SkipPaths { get; set; }

Skip attestation check for these paths (regex patterns).

class ByteCountingStream

public sealed class ByteCountingStream : Stream

A stream wrapper that counts bytes read and enforces a limit.

Members

MemberKindSummary
ByteCountingStream(Stream, long, Action)constructorInitializes a new instance of the ByteCountingStreamclass.
BytesReadpropertyGets the total number of bytes read from this stream.
CanReadpropertySee Stream.CanRead.
CanSeekpropertySee Stream.CanSeek.
CanWritepropertySee Stream.CanWrite.
LengthpropertySee Stream.Length.
PositionpropertySee Stream.Position.
DisposeAsync()methodSee Stream.DisposeAsync().
Flush()methodSee Stream.Flush().
FlushAsync(CancellationToken)methodSee Stream.FlushAsync(CancellationToken).
Read(byte[], int, int)methodSee Stream.Read(byte[], int, int).
ReadAsync(Memory<byte>, CancellationToken)methodSee Stream.ReadAsync(Memory<byte>, CancellationToken).
ReadAsync(byte[], int, int, CancellationToken)methodSee Stream.ReadAsync(byte[], int, int, CancellationToken).
Seek(long, SeekOrigin)methodSee Stream.Seek(long, SeekOrigin).
SetLength(long)methodSee Stream.SetLength(long).
Write(byte[], int, int)methodSee Stream.Write(byte[], int, int).

constructor ByteCountingStream(Stream, long, Action) #

public ByteCountingStream(Stream inner, long limit, Action? onLimitExceeded = null)

Initializes a new instance of the ByteCountingStreamclass.

Parameters

  • inner: The inner stream to wrap.
  • limit: The maximum number of bytes that can be read.
  • onLimitExceeded: Optional callback invoked when the limit is exceeded.

property BytesRead #

public long BytesRead { get; }

Gets the total number of bytes read from this stream.

property CanRead #

public override bool CanRead { get; }

See Stream.CanRead.

property CanSeek #

public override bool CanSeek { get; }

See Stream.CanSeek.

property CanWrite #

public override bool CanWrite { get; }

See Stream.CanWrite.

property Length #

public override long Length { get; }

See Stream.Length.

property Position #

public override long Position { get; set; }

See Stream.Position.

method DisposeAsync() #

public override ValueTask DisposeAsync()

See Stream.DisposeAsync().

method Flush() #

public override void Flush()

See Stream.Flush().

method FlushAsync(CancellationToken) #

public override Task FlushAsync(CancellationToken cancellationToken)

See Stream.FlushAsync(CancellationToken).

method Read(byte[], int, int) #

public override int Read(byte[] buffer, int offset, int count)

See Stream.Read(byte[], int, int).

method ReadAsync(Memory<byte>, CancellationToken) #

public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default)

See Stream.ReadAsync(Memory<byte>, CancellationToken).

method ReadAsync(byte[], int, int, CancellationToken) #

public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)

See Stream.ReadAsync(byte[], int, int, CancellationToken).

method Seek(long, SeekOrigin) #

public override long Seek(long offset, SeekOrigin origin)

See Stream.Seek(long, SeekOrigin).

method SetLength(long) #

public override void SetLength(long value)

See Stream.SetLength(long).

method Write(byte[], int, int) #

public override void Write(byte[] buffer, int offset, int count)

See Stream.Write(byte[], int, int).

class DefaultAttestationLookupService

public sealed class DefaultAttestationLookupService : IAttestationLookupService

Default implementation of attestation lookup service.

Members

MemberKindSummary
DefaultAttestationLookupService(ILogger<DefaultAttestationLookupService>, HttpClient, string)constructorCreates the lookup service.
CheckAttestationsAsync(string, IEnumerable<string>, CancellationToken)methodLooks up attestations for an artifact digest.

constructor DefaultAttestationLookupService(ILogger<DefaultAttestationLookupService>, HttpClient, string) #

public DefaultAttestationLookupService(ILogger<DefaultAttestationLookupService> logger, HttpClient? httpClient = null, string? attestorUrl = null)

Creates the lookup service.

Parameters

  • logger: Receives the diagnostics.
  • httpClient: The client that calls the attestor; none when not set.
  • attestorUrl: The attestor address; none when not set.

method CheckAttestationsAsync(string, IEnumerable<string>, CancellationToken) #

public Task<AttestationCheckResult> CheckAttestationsAsync(string digest, IEnumerable<string> requiredTypes, CancellationToken ct = default)

Looks up attestations for an artifact digest.

class EndpointResolutionMiddleware

public sealed class EndpointResolutionMiddleware

Resolves incoming HTTP requests to endpoint descriptors using the routing state.

Members

MemberKindSummary
EndpointResolutionMiddleware(RequestDelegate, IOptions<RoutingOptions>)constructorInitializes a new instance of the EndpointResolutionMiddlewareclass.
Invoke(HttpContext, IGlobalRoutingState)methodInvokes the middleware.

constructor EndpointResolutionMiddleware(RequestDelegate, IOptions<RoutingOptions>) #

public EndpointResolutionMiddleware(RequestDelegate next, IOptions<RoutingOptions>? routingOptions = null)

Initializes a new instance of the EndpointResolutionMiddlewareclass.

Parameters

  • next: The next middleware.
  • routingOptions: The routing options; their default version applies to a request that names none.

method Invoke(HttpContext, IGlobalRoutingState) #

public Task Invoke(HttpContext context, IGlobalRoutingState routingState)

Invokes the middleware.

class GlobalErrorHandlerMiddleware

public sealed class GlobalErrorHandlerMiddleware

Catches unhandled exceptions and returns a structured JSON error response.

Members

MemberKindSummary
GlobalErrorHandlerMiddleware(RequestDelegate, ILogger<GlobalErrorHandlerMiddleware>, IHostEnvironment)constructorCreates the middleware.
Invoke(HttpContext)methodRuns the rest of the pipeline and answers an unhandled exception with a 500 problem response.

constructor GlobalErrorHandlerMiddleware(RequestDelegate, ILogger<GlobalErrorHandlerMiddleware>, IHostEnvironment) #

public GlobalErrorHandlerMiddleware(RequestDelegate next, ILogger<GlobalErrorHandlerMiddleware> logger, IHostEnvironment environment)

Creates the middleware.

Parameters

  • next: The next middleware.
  • logger: Receives the diagnostics.
  • environment: The host environment.

method Invoke(HttpContext) #

public Task Invoke(HttpContext context)

Runs the rest of the pipeline and answers an unhandled exception with a 500 problem response.

Parameters

  • context: The HTTP context.

Returns

A task that completes when the request is handled.

interface IAttestationLookupService

public interface IAttestationLookupService

Service for looking up attestations.

Members

MemberKindSummary
CheckAttestationsAsync(string, IEnumerable<string>, CancellationToken)methodLooks up attestations for an artifact digest.

method CheckAttestationsAsync(string, IEnumerable<string>, CancellationToken) #

Task<AttestationCheckResult> CheckAttestationsAsync(string digest, IEnumerable<string> requiredTypes, CancellationToken ct = default)

Looks up attestations for an artifact digest.

interface IPayloadTracker

public interface IPayloadTracker

Tracks payload bytes across requests, connections, and globally.

Members

MemberKindSummary
CurrentInflightBytespropertyGets the current total inflight bytes across all connections.
IsOverloadedpropertyGets a value indicating whether the system is overloaded.
GetConnectionInflightBytes(string)methodGets the current inflight bytes for a specific connection.
Release(string, long)methodReleases previously reserved capacity.
TryReserve(string, long)methodTries to reserve capacity for an estimated payload size.

property CurrentInflightBytes #

long CurrentInflightBytes { get; }

Gets the current total inflight bytes across all connections.

property IsOverloaded #

bool IsOverloaded { get; }

Gets a value indicating whether the system is overloaded.

method GetConnectionInflightBytes(string) #

long GetConnectionInflightBytes(string connectionId)

Gets the current inflight bytes for a specific connection.

Parameters

  • connectionId: The connection identifier.

Returns

The current inflight bytes for the connection.

method Release(string, long) #

void Release(string connectionId, long actualBytes)

Releases previously reserved capacity.

Parameters

  • connectionId: The connection identifier.
  • actualBytes: The actual bytes to release.

method TryReserve(string, long) #

bool TryReserve(string connectionId, long estimatedBytes)

Tries to reserve capacity for an estimated payload size.

Parameters

  • connectionId: The connection identifier.
  • estimatedBytes: The estimated bytes to reserve.

Returns

True if capacity was reserved; false if limits would be exceeded.

class PayloadLimitExceededException

public sealed class PayloadLimitExceededException : Exception

Exception thrown when a payload limit is exceeded during streaming.

Members

MemberKindSummary
PayloadLimitExceededException(long, long)constructorInitializes a new instance of the PayloadLimitExceededExceptionclass.
BytesReadpropertyGets the number of bytes read before the limit was exceeded.
LimitpropertyGets the limit that was exceeded.

constructor PayloadLimitExceededException(long, long) #

public PayloadLimitExceededException(long bytesRead, long limit)

Initializes a new instance of the PayloadLimitExceededExceptionclass.

Parameters

  • bytesRead: The number of bytes read before the limit was exceeded.
  • limit: The limit that was exceeded.

property BytesRead #

public long BytesRead { get; }

Gets the number of bytes read before the limit was exceeded.

property Limit #

public long Limit { get; }

Gets the limit that was exceeded.

class PayloadLimitsMiddleware

public sealed class PayloadLimitsMiddleware

Middleware that enforces payload limits per-request, per-connection, and aggregate.

Members

MemberKindSummary
PayloadLimitsMiddleware(RequestDelegate, IOptions<PayloadLimits>, ILogger<PayloadLimitsMiddleware>)constructorInitializes a new instance of the PayloadLimitsMiddlewareclass.
Invoke(HttpContext, IPayloadTracker)methodInvokes the middleware.

constructor PayloadLimitsMiddleware(RequestDelegate, IOptions<PayloadLimits>, ILogger<PayloadLimitsMiddleware>) #

public PayloadLimitsMiddleware(RequestDelegate next, IOptions<PayloadLimits> limits, ILogger<PayloadLimitsMiddleware> logger)

Initializes a new instance of the PayloadLimitsMiddlewareclass.

method Invoke(HttpContext, IPayloadTracker) #

public Task Invoke(HttpContext context, IPayloadTracker tracker)

Invokes the middleware.

class PayloadTracker

public sealed class PayloadTracker : IPayloadTracker

Default implementation of IPayloadTracker.

Members

MemberKindSummary
PayloadTracker(IOptions<PayloadLimits>, ILogger<PayloadTracker>)constructorInitializes a new instance of the PayloadTrackerclass.
CurrentInflightBytespropertyGets the current total inflight bytes across all connections.
IsOverloadedpropertyGets a value indicating whether the system is overloaded.
GetConnectionInflightBytes(string)methodGets the current inflight bytes for a specific connection.
Release(string, long)methodReleases previously reserved capacity.
TryReserve(string, long)methodTries to reserve capacity for an estimated payload size.

constructor PayloadTracker(IOptions<PayloadLimits>, ILogger<PayloadTracker>) #

public PayloadTracker(IOptions<PayloadLimits> limits, ILogger<PayloadTracker> logger)

Initializes a new instance of the PayloadTrackerclass.

property CurrentInflightBytes #

public long CurrentInflightBytes { get; }

Gets the current total inflight bytes across all connections.

property IsOverloaded #

public bool IsOverloaded { get; }

Gets a value indicating whether the system is overloaded.

method GetConnectionInflightBytes(string) #

public long GetConnectionInflightBytes(string connectionId)

Gets the current inflight bytes for a specific connection.

Parameters

  • connectionId: The connection identifier.

Returns

The current inflight bytes for the connection.

method Release(string, long) #

public void Release(string connectionId, long actualBytes)

Releases previously reserved capacity.

Parameters

  • connectionId: The connection identifier.
  • actualBytes: The actual bytes to release.

method TryReserve(string, long) #

public bool TryReserve(string connectionId, long estimatedBytes)

Tries to reserve capacity for an estimated payload size.

Parameters

  • connectionId: The connection identifier.
  • estimatedBytes: The estimated bytes to reserve.

Returns

True if capacity was reserved; false if limits would be exceeded.

class RequestLoggingMiddleware

public sealed class RequestLoggingMiddleware

Logs basic request/response information for gateway requests.

Members

MemberKindSummary
RequestLoggingMiddleware(RequestDelegate, ILogger<RequestLoggingMiddleware>)constructorCreates the middleware.
Invoke(HttpContext)methodRuns the rest of the pipeline and logs the request with its status and duration.

constructor RequestLoggingMiddleware(RequestDelegate, ILogger<RequestLoggingMiddleware>) #

public RequestLoggingMiddleware(RequestDelegate next, ILogger<RequestLoggingMiddleware> logger)

Creates the middleware.

Parameters

  • next: The next middleware.
  • logger: Receives the diagnostics.

method Invoke(HttpContext) #

public Task Invoke(HttpContext context)

Runs the rest of the pipeline and logs the request with its status and duration.

Parameters

  • context: The HTTP context.

Returns

A task that completes when the request is handled.

class RouterErrorWriter

public static class RouterErrorWriter

The gateway’s single writer for error responses. Public so the gateway host’s own middlewares (for example break-glass introspection) refuse with the same RFC 7807 envelope as the routing pipeline instead of an ad hoc JSON body.

Members

MemberKindSummary
WriteAsync(HttpContext, int, string, string, string, string, IReadOnlyDictionary<string, object>, CancellationToken)methodWrites an RFC 7807 problem response, unless the response has started.

method WriteAsync(HttpContext, int, string, string, string, string, IReadOnlyDictionary<string, object>, CancellationToken) #

public static Task WriteAsync(HttpContext context, int statusCode, string error, string? message = null, string? service = null, string? version = null, IReadOnlyDictionary<string, object?>? details = null, CancellationToken cancellationToken = default)

Writes an RFC 7807 problem response, unless the response has started.

Parameters

  • context: The HTTP context.
  • statusCode: The status code.
  • error: The error title.
  • message: The detail.
  • service: The service the request was for.
  • version: The service version.
  • details: Structured details.
  • cancellationToken: Cancels the write.

Returns

A task that completes when the response is written.

class RoutingDecisionMiddleware

public sealed class RoutingDecisionMiddleware

Makes routing decisions for resolved endpoints.

Members

MemberKindSummary
RoutingDecisionMiddleware(RequestDelegate)constructorInitializes a new instance of the RoutingDecisionMiddlewareclass.
Invoke(HttpContext, IRoutingPlugin, IGlobalRoutingState, IOptions<RouterNodeConfig>, IOptions<RoutingOptions>)methodInvokes the middleware.

constructor RoutingDecisionMiddleware(RequestDelegate) #

public RoutingDecisionMiddleware(RequestDelegate next)

Initializes a new instance of the RoutingDecisionMiddlewareclass.

method Invoke(HttpContext, IRoutingPlugin, IGlobalRoutingState, IOptions<RouterNodeConfig>, IOptions<RoutingOptions>) #

public Task Invoke(HttpContext context, IRoutingPlugin routingPlugin, IGlobalRoutingState routingState, IOptions<RouterNodeConfig> gatewayConfig, IOptions<RoutingOptions> routingOptions)

Invokes the middleware.

class TransportDispatchMiddleware

public sealed class TransportDispatchMiddleware

Dispatches HTTP requests to microservices via the transport layer.

Members

MemberKindSummary
TransportDispatchMiddleware(RequestDelegate, ILogger<TransportDispatchMiddleware>, IHostEnvironment, IOptions<PayloadLimits>)constructorInitializes a new instance of the TransportDispatchMiddlewareclass.
Invoke(HttpContext, ITransportClient, IGlobalRoutingState, IRouterGatewayMetrics)methodInvokes the middleware.

constructor TransportDispatchMiddleware(RequestDelegate, ILogger<TransportDispatchMiddleware>, IHostEnvironment, IOptions<PayloadLimits>) #

public TransportDispatchMiddleware(RequestDelegate next, ILogger<TransportDispatchMiddleware> logger, IHostEnvironment environment, IOptions<PayloadLimits> limits)

Initializes a new instance of the TransportDispatchMiddlewareclass.

Parameters

  • next: The next middleware.
  • logger: The logger.
  • environment: The host environment.
  • limits: The payload limits; the streaming dispatch reads the request body up to PayloadLimits.MaxRequestBytesPerCall.

method Invoke(HttpContext, ITransportClient, IGlobalRoutingState, IRouterGatewayMetrics) #

public Task Invoke(HttpContext context, ITransportClient transportClient, IGlobalRoutingState routingState, IRouterGatewayMetrics metrics)

Invokes the middleware.

namespace StellaOps.Router.Gateway.OpenApi

TypeKindDescription
GatewayRouteCatalogclassProvides the configured gateway route table for OpenAPI path projection.
IOpenApiDocumentGeneratorinterfaceGenerates OpenAPI documents from aggregated microservice schemas.
IRouterOpenApiDocumentCacheinterfaceCaches the generated OpenAPI document with TTL-based expiration.
OpenApiAggregationOptionsclassConfiguration options for OpenAPI document aggregation.
OpenApiDocumentGeneratorclassGenerates OpenAPI 3.1.0 documents from aggregated microservice schemas.
OpenApiEndpointsclassEndpoints for serving OpenAPI documentation.
OpenApiYamlclassWrites an OpenAPI document given as JSON as YAML.
RouterOpenApiDocumentCacheclassCaches the generated OpenAPI document with TTL-based expiration.

class GatewayRouteCatalog

public sealed class GatewayRouteCatalog

Provides the configured gateway route table for OpenAPI path projection.

Members

MemberKindSummary
GatewayRouteCatalog(IEnumerable<StellaOpsRoute>)constructorInitializes a new instance of the GatewayRouteCatalogclass.
RoutespropertyGets the configured gateway routes.

constructor GatewayRouteCatalog(IEnumerable<StellaOpsRoute>) #

public GatewayRouteCatalog(IEnumerable<StellaOpsRoute> routes)

Initializes a new instance of the GatewayRouteCatalogclass.

Parameters

  • routes: Configured gateway routes.

property Routes #

public IReadOnlyList<StellaOpsRoute> Routes { get; }

Gets the configured gateway routes.

interface IOpenApiDocumentGenerator

public interface IOpenApiDocumentGenerator

Generates OpenAPI documents from aggregated microservice schemas.

Members

MemberKindSummary
GenerateDocument()methodGenerates the OpenAPI 3.1.0 document as JSON.

method GenerateDocument() #

string GenerateDocument()

Generates the OpenAPI 3.1.0 document as JSON.

Returns

The OpenAPI document as a JSON string.

interface IRouterOpenApiDocumentCache

public interface IRouterOpenApiDocumentCache

Caches the generated OpenAPI document with TTL-based expiration.

Members

MemberKindSummary
GetDocument()methodGets the cached document or regenerates if expired.
Invalidate()methodInvalidates the cache, forcing regeneration on next access.

method GetDocument() #

(string DocumentJson, string ETag, DateTime GeneratedAt) GetDocument()

Gets the cached document or regenerates if expired.

Returns

A tuple containing the document JSON, ETag, and generation timestamp.

method Invalidate() #

void Invalidate()

Invalidates the cache, forcing regeneration on next access.

class OpenApiAggregationOptions

public sealed class OpenApiAggregationOptions

Configuration options for OpenAPI document aggregation.

Members

MemberKindSummary
OpenApiAggregationOptions()constructorCreates an instance of OpenApiAggregationOptions.
SectionNameconstantThe configuration section name.
CacheTtlSecondspropertyGets or sets the cache TTL in seconds.
ContactEmailpropertyGets or sets the contact email.
ContactNamepropertyGets or sets the contact name.
DescriptionpropertyGets or sets the API description.
EnabledpropertyGets or sets whether OpenAPI aggregation is enabled.
LicenseNamepropertyGets or sets the license name of the API the document describes (info.license.name).
ServerUrlpropertyGets or sets the server URL.
TitlepropertyGets or sets the API title.
TokenUrlpropertyGets or sets the OAuth2 token URL of the client-credentials flow that the scopes of the endpoints are obtained from.
VersionpropertyGets or sets the API version.

constructor OpenApiAggregationOptions() #

public OpenApiAggregationOptions()

Creates an instance of OpenApiAggregationOptions.

constant SectionName #

public const string SectionName = "Router:OpenApi"

The configuration section name.

property CacheTtlSeconds #

public int CacheTtlSeconds { get; set; }

Gets or sets the cache TTL in seconds.

property ContactEmail #

public string? ContactEmail { get; set; }

Gets or sets the contact email.

property ContactName #

public string? ContactName { get; set; }

Gets or sets the contact name.

property Description #

public string Description { get; set; }

Gets or sets the API description.

property Enabled #

public bool Enabled { get; set; }

Gets or sets whether OpenAPI aggregation is enabled.

property LicenseName #

public string? LicenseName { get; set; }

Gets or sets the license name of the API the document describes (info.license.name). Unset by default, so the document states no license.

property ServerUrl #

public string ServerUrl { get; set; }

Gets or sets the server URL.

property Title #

public string Title { get; set; }

Gets or sets the API title.

property TokenUrl #

public string? TokenUrl { get; set; }

Gets or sets the OAuth2 token URL of the client-credentials flow that the scopes of the endpoints are obtained from. Unset by default: the document then declares the bearer scheme only, and lists no OAuth2 scheme or scopes in the operations’ security requirements.

property Version #

public string Version { get; set; }

Gets or sets the API version.

class OpenApiDocumentGenerator

public sealed class OpenApiDocumentGenerator : IOpenApiDocumentGenerator

Generates OpenAPI 3.1.0 documents from aggregated microservice schemas.

Members

MemberKindSummary
OpenApiDocumentGenerator(IGlobalRoutingState, IOptions<OpenApiAggregationOptions>, GatewayRouteCatalog, IOptions<RoutingOptions>, IEffectiveClaimsStore)constructorCreates the generator.
GenerateDocument()methodGenerates the OpenAPI 3.1.0 document as JSON.

constructor OpenApiDocumentGenerator(IGlobalRoutingState, IOptions<OpenApiAggregationOptions>, GatewayRouteCatalog, IOptions<RoutingOptions>, IEffectiveClaimsStore) #

public OpenApiDocumentGenerator(IGlobalRoutingState routingState, IOptions<OpenApiAggregationOptions> options, GatewayRouteCatalog? routeCatalog = null, IOptions<RoutingOptions>? routingOptions = null, IEffectiveClaimsStore? effectiveClaimsStore = null)

Creates the generator.

Parameters

  • routingState: The connected instances and their endpoints.
  • options: The OpenAPI document settings.
  • routeCatalog: The static routes, when there are any.
  • routingOptions: The routing options, when given.
  • effectiveClaimsStore: The effective claim requirements, when given.

method GenerateDocument() #

public string GenerateDocument()

Generates the OpenAPI 3.1.0 document as JSON.

Returns

The OpenAPI document as a JSON string.

class OpenApiEndpoints

public static class OpenApiEndpoints

Endpoints for serving OpenAPI documentation.

Members

MemberKindSummary
MapRouterOpenApiEndpoints(IEndpointRouteBuilder)extension methodMaps OpenAPI endpoints to the application.

extension method MapRouterOpenApiEndpoints(IEndpointRouteBuilder) #

public static IEndpointRouteBuilder MapRouterOpenApiEndpoints(this IEndpointRouteBuilder endpoints)

Maps OpenAPI endpoints to the application.

class OpenApiYaml

public static class OpenApiYaml

Writes an OpenAPI document given as JSON as YAML. Every JSON object becomes a mapping, every array a sequence and every scalar (string, number, boolean, null) a YAML scalar of the same value; a string that YAML would read as another type is quoted. Both gateway hosts serve /openapi.yaml with it.

Members

MemberKindSummary
FromJson(JsonNode)methodConverts a parsed OpenAPI document to YAML; an empty string for null.
FromJson(string)methodConverts the JSON text of an OpenAPI document to YAML; an empty string for a JSON null.

method FromJson(JsonNode) #

public static string FromJson(JsonNode? document)

Converts a parsed OpenAPI document to YAML; an empty string for null.

Parameters

  • document: The parsed document.

Returns

The document as YAML.

method FromJson(string) #

public static string FromJson(string documentJson)

Converts the JSON text of an OpenAPI document to YAML; an empty string for a JSON null.

Parameters

  • documentJson: The document as JSON.

Returns

The document as YAML.

class RouterOpenApiDocumentCache

public sealed class RouterOpenApiDocumentCache : IRouterOpenApiDocumentCache

Caches the generated OpenAPI document with TTL-based expiration.

Members

MemberKindSummary
RouterOpenApiDocumentCache(IOpenApiDocumentGenerator, IOptions<OpenApiAggregationOptions>)constructorCreates the cache.
GetDocument()methodGets the cached document or regenerates if expired.
Invalidate()methodInvalidates the cache, forcing regeneration on next access.

constructor RouterOpenApiDocumentCache(IOpenApiDocumentGenerator, IOptions<OpenApiAggregationOptions>) #

public RouterOpenApiDocumentCache(IOpenApiDocumentGenerator generator, IOptions<OpenApiAggregationOptions> options)

Creates the cache.

Parameters

  • generator: Builds the document.
  • options: The OpenAPI settings, with the cache lifetime.

method GetDocument() #

public (string DocumentJson, string ETag, DateTime GeneratedAt) GetDocument()

Gets the cached document or regenerates if expired.

Returns

A tuple containing the document JSON, ETag, and generation timestamp.

method Invalidate() #

public void Invalidate()

Invalidates the cache, forcing regeneration on next access.

namespace StellaOps.Router.Gateway.RateLimit

TypeKindDescription
CircuitBreakerclassCircuit breaker for Valkey operations.
CircuitBreakerConfigclassCircuit breaker configuration for Valkey resilience.
CircuitStateenumCircuit breaker state.
EnvironmentLimitsConfigclassEnvironment-level rate limit configuration (Valkey-backed).
EnvironmentRateLimiterclassValkey-backed rate limiter for environment-level protection.
IValkeyRateLimitStoreinterfaceInterface for Valkey rate limit store operations.
InMemoryValkeyRateLimitStoreclassIn-memory fixed-window rate limit store (primarily for tests).
InstanceLimitsConfigclassInstance-level rate limit configuration (in-memory).
InstanceRateLimiterclassIn-memory rate limiter for instance-level protection.
MicroserviceLimitsConfigclassPer-microservice rate limit overrides.
RateLimitConfigclassRoot configuration for Router rate limiting.
RateLimitDecisionrecordResult of a rate limit check.
RateLimitMetricsclassOpenTelemetry metrics for Router rate limiting.
RateLimitMiddlewareclassMiddleware that enforces rate limits on incoming requests.
RateLimitRuleclassA single rate limit rule (window + max requests).
RateLimitScopeenumRate limit scope.
RateLimitServiceclassService that orchestrates rate limit checks across instance and environment scopes.
RateLimitServiceCollectionExtensionsclassExtension methods for registering rate limiting services.
RateLimitStoreResultrecordResult of a Valkey rate limit check.
RouteLimitsConfigclassPer-route rate limit configuration.
RouteMatchTypeenumHow a route rate limit pattern matches a request path.

class CircuitBreaker

public sealed class CircuitBreaker

Circuit breaker for Valkey operations. Provides fail-open behavior when Valkey is unavailable.

Members

MemberKindSummary
CircuitBreaker(int, int, int)constructorCreates a closed circuit breaker.
IsHalfOpenpropertyWhether the circuit is half-open (testing recovery).
IsOpenpropertyWhether the circuit is open (requests should bypass Valkey).
StatepropertyCurrent state of the circuit.
RecordFailure()methodRecord a failed operation.
RecordSuccess()methodRecord a successful operation.
Reset()methodReset the circuit breaker.

constructor CircuitBreaker(int, int, int) #

public CircuitBreaker(int failureThreshold, int timeoutSeconds, int halfOpenTimeout)

Creates a closed circuit breaker.

Parameters

  • failureThreshold: The failures that open the circuit, at least 1.
  • timeoutSeconds: How long the circuit stays open, in seconds, at least 1.
  • halfOpenTimeout: How long the circuit stays half open, in seconds, at least 1.

property IsHalfOpen #

public bool IsHalfOpen { get; }

Whether the circuit is half-open (testing recovery).

property IsOpen #

public bool IsOpen { get; }

Whether the circuit is open (requests should bypass Valkey).

property State #

public CircuitState State { get; }

Current state of the circuit.

method RecordFailure() #

public void RecordFailure()

Record a failed operation.

method RecordSuccess() #

public void RecordSuccess()

Record a successful operation.

method Reset() #

public void Reset()

Reset the circuit breaker.

class CircuitBreakerConfig

public sealed class CircuitBreakerConfig

Circuit breaker configuration for Valkey resilience.

Members

MemberKindSummary
CircuitBreakerConfig()constructorCreates an instance of CircuitBreakerConfig.
FailureThresholdpropertyNumber of failures before opening the circuit.
HalfOpenTimeoutpropertySeconds in half-open state before full reset.
TimeoutSecondspropertySeconds to keep circuit open.
Validate(string)methodValidate configuration.

constructor CircuitBreakerConfig() #

public CircuitBreakerConfig()

Creates an instance of CircuitBreakerConfig.

property FailureThreshold #

public int FailureThreshold { get; set; }

Number of failures before opening the circuit.

property HalfOpenTimeout #

public int HalfOpenTimeout { get; set; }

Seconds in half-open state before full reset.

property TimeoutSeconds #

public int TimeoutSeconds { get; set; }

Seconds to keep circuit open.

method Validate(string) #

public void Validate(string path)

Validate configuration.

enum CircuitState

public enum CircuitState

Circuit breaker state.

ValueDescription
Closed = 0Circuit is closed, requests flow through.
Open = 1Circuit is open, requests are blocked.
HalfOpen = 2Circuit is testing recovery.

class EnvironmentLimitsConfig

public sealed class EnvironmentLimitsConfig

Environment-level rate limit configuration (Valkey-backed).

Members

MemberKindSummary
EnvironmentLimitsConfig()constructorCreates an instance of EnvironmentLimitsConfig.
AllowBurstForSecondspropertyBurst window in seconds.
AllowMaxBurstRequestspropertyMaximum burst requests.
CircuitBreakerpropertyCircuit breaker configuration.
MaxRequestspropertyMaximum requests in the time window.
MicroservicespropertyPer-microservice overrides.
PerSecondspropertyTime window in seconds.
RulespropertyMulti-rule configuration (preferred).
ValkeyBucketpropertyValkey bucket/prefix for rate limit keys.
ValkeyConnectionpropertyValkey connection string.
GetEffectiveRules()methodThe rules in effect: rules when it has any; otherwise a long rule from per_seconds and max_requests and a burst rule from the burst settings, each when both values are set.
Validate(string)methodValidate configuration.

constructor EnvironmentLimitsConfig() #

public EnvironmentLimitsConfig()

Creates an instance of EnvironmentLimitsConfig.

property AllowBurstForSeconds #

public int AllowBurstForSeconds { get; set; }

Burst window in seconds.

property AllowMaxBurstRequests #

public int AllowMaxBurstRequests { get; set; }

Maximum burst requests.

property CircuitBreaker #

public CircuitBreakerConfig? CircuitBreaker { get; set; }

Circuit breaker configuration.

property MaxRequests #

public int MaxRequests { get; set; }

Maximum requests in the time window.

property Microservices #

public Dictionary<string, MicroserviceLimitsConfig>? Microservices { get; set; }

Per-microservice overrides.

property PerSeconds #

public int PerSeconds { get; set; }

Time window in seconds.

property Rules #

public List<RateLimitRule> Rules { get; set; }

Multi-rule configuration (preferred). When specified, takes precedence over the single-window fields.

property ValkeyBucket #

public string ValkeyBucket { get; set; }

Valkey bucket/prefix for rate limit keys.

property ValkeyConnection #

public string ValkeyConnection { get; set; }

Valkey connection string.

method GetEffectiveRules() #

public IReadOnlyList<RateLimitRule> GetEffectiveRules()

The rules in effect: rules when it has any; otherwise a long rule from per_seconds and max_requests and a burst rule from the burst settings, each when both values are set.

Returns

The rules in effect.

method Validate(string) #

public void Validate(string path)

Validate configuration.

class EnvironmentRateLimiter

public sealed class EnvironmentRateLimiter : IDisposable

Valkey-backed rate limiter for environment-level protection. Uses fixed-window counters with atomic Lua operations.

Members

MemberKindSummary
EnvironmentRateLimiter(IValkeyRateLimitStore, CircuitBreaker, ILogger<EnvironmentRateLimiter>)constructorCreates the limiter.
Dispose()methodReleases the limiter.
TryAcquireAsync(string, string, IReadOnlyList<RateLimitRule>, CancellationToken)methodTry to acquire a request slot.

constructor EnvironmentRateLimiter(IValkeyRateLimitStore, CircuitBreaker, ILogger<EnvironmentRateLimiter>) #

public EnvironmentRateLimiter(IValkeyRateLimitStore store, CircuitBreaker circuitBreaker, ILogger<EnvironmentRateLimiter> logger)

Creates the limiter.

Parameters

  • store: The shared counter store.
  • circuitBreaker: Stops calls to the store after repeated failures.
  • logger: Receives the diagnostics.

method Dispose() #

public void Dispose()

Releases the limiter.

method TryAcquireAsync(string, string, IReadOnlyList<RateLimitRule>, CancellationToken) #

public Task<RateLimitDecision?> TryAcquireAsync(string microservice, string targetKey, IReadOnlyList<RateLimitRule> rules, CancellationToken cancellationToken)

Try to acquire a request slot. Returns null if circuit breaker is open (fail-open behavior).

interface IValkeyRateLimitStore

public interface IValkeyRateLimitStore

Interface for Valkey rate limit store operations.

Members

MemberKindSummary
IncrementAndCheckAsync(string, IReadOnlyList<RateLimitRule>, CancellationToken)methodAtomically increment counters for the provided rules and determine if the request is allowed.

method IncrementAndCheckAsync(string, IReadOnlyList<RateLimitRule>, CancellationToken) #

Task<RateLimitStoreResult> IncrementAndCheckAsync(string key, IReadOnlyList<RateLimitRule> rules, CancellationToken cancellationToken)

Atomically increment counters for the provided rules and determine if the request is allowed.

class InMemoryValkeyRateLimitStore

public sealed class InMemoryValkeyRateLimitStore : IValkeyRateLimitStore

In-memory fixed-window rate limit store (primarily for tests).

Members

MemberKindSummary
InMemoryValkeyRateLimitStore()constructorCreates an instance of InMemoryValkeyRateLimitStore.
IncrementAndCheckAsync(string, IReadOnlyList<RateLimitRule>, CancellationToken)methodAtomically increment counters for the provided rules and determine if the request is allowed.
Reset()methodClears every counter.

constructor InMemoryValkeyRateLimitStore() #

public InMemoryValkeyRateLimitStore()

Creates an instance of InMemoryValkeyRateLimitStore.

method IncrementAndCheckAsync(string, IReadOnlyList<RateLimitRule>, CancellationToken) #

public Task<RateLimitStoreResult> IncrementAndCheckAsync(string key, IReadOnlyList<RateLimitRule> rules, CancellationToken cancellationToken)

Atomically increment counters for the provided rules and determine if the request is allowed.

method Reset() #

public void Reset()

Clears every counter.

class InstanceLimitsConfig

public sealed class InstanceLimitsConfig

Instance-level rate limit configuration (in-memory).

Members

MemberKindSummary
InstanceLimitsConfig()constructorCreates an instance of InstanceLimitsConfig.
AllowBurstForSecondspropertyBurst window in seconds.
AllowMaxBurstRequestspropertyMaximum burst requests.
MaxRequestspropertyMaximum requests in the time window.
PerSecondspropertyTime window in seconds.
RulespropertyMulti-rule configuration (preferred).
GetEffectiveRules()methodThe rules in effect: rules when it has any; otherwise a long rule from per_seconds and max_requests and a burst rule from the burst settings, each when both values are set.
Validate(string)methodValidate configuration.

constructor InstanceLimitsConfig() #

public InstanceLimitsConfig()

Creates an instance of InstanceLimitsConfig.

property AllowBurstForSeconds #

public int AllowBurstForSeconds { get; set; }

Burst window in seconds.

property AllowMaxBurstRequests #

public int AllowMaxBurstRequests { get; set; }

Maximum burst requests.

property MaxRequests #

public int MaxRequests { get; set; }

Maximum requests in the time window.

property PerSeconds #

public int PerSeconds { get; set; }

Time window in seconds.

property Rules #

public List<RateLimitRule> Rules { get; set; }

Multi-rule configuration (preferred). When specified, takes precedence over the single-window fields.

method GetEffectiveRules() #

public IReadOnlyList<RateLimitRule> GetEffectiveRules()

The rules in effect: rules when it has any; otherwise a long rule from per_seconds and max_requests and a burst rule from the burst settings, each when both values are set.

Returns

The rules in effect.

method Validate(string) #

public void Validate(string path)

Validate configuration.

class InstanceRateLimiter

public sealed class InstanceRateLimiter : IDisposable

In-memory rate limiter for instance-level protection. Uses sliding window counters for fair rate limiting.

Members

MemberKindSummary
InstanceRateLimiter(IReadOnlyList<RateLimitRule>, TimeProvider)constructorCreate instance rate limiter with default limits.
Dispose()methodReleases the limiter.
GetCurrentCount(string)methodGet current request count for a microservice.
Reset()methodReset counters (for testing).
TryAcquire(string, IReadOnlyList<RateLimitRule>)methodTry to acquire a request slot.

constructor InstanceRateLimiter(IReadOnlyList<RateLimitRule>, TimeProvider) #

public InstanceRateLimiter(IReadOnlyList<RateLimitRule> defaultRules, TimeProvider? timeProvider = null)

Create instance rate limiter with default limits.

method Dispose() #

public void Dispose()

Releases the limiter.

method GetCurrentCount(string) #

public long GetCurrentCount(string microservice)

Get current request count for a microservice.

method Reset() #

public void Reset()

Reset counters (for testing).

method TryAcquire(string, IReadOnlyList<RateLimitRule>) #

public RateLimitDecision TryAcquire(string microservice, IReadOnlyList<RateLimitRule>? rules = null)

Try to acquire a request slot.

Parameters

  • microservice: Target microservice name.
  • rules: Optional rule overrides.

Returns

Decision indicating whether request is allowed.

class MicroserviceLimitsConfig

public sealed class MicroserviceLimitsConfig

Per-microservice rate limit overrides.

Members

MemberKindSummary
MicroserviceLimitsConfig()constructorCreates an instance of MicroserviceLimitsConfig.
AllowBurstForSecondspropertyBurst window in seconds (optional).
AllowMaxBurstRequestspropertyMaximum burst requests (optional).
MaxRequestspropertyMaximum requests in the time window.
PerSecondspropertyTime window in seconds.
RoutespropertyPer-route overrides (best match wins).
RulespropertyMulti-rule configuration (preferred).
GetEffectiveRules()methodThe rules in effect: rules when it has any; otherwise a long rule from per_seconds and max_requests and a burst rule from the burst settings, each when both values are set.
Validate(string)methodValidate configuration.

constructor MicroserviceLimitsConfig() #

public MicroserviceLimitsConfig()

Creates an instance of MicroserviceLimitsConfig.

property AllowBurstForSeconds #

public int? AllowBurstForSeconds { get; set; }

Burst window in seconds (optional).

property AllowMaxBurstRequests #

public int? AllowMaxBurstRequests { get; set; }

Maximum burst requests (optional).

property MaxRequests #

public int? MaxRequests { get; set; }

Maximum requests in the time window.

property PerSeconds #

public int? PerSeconds { get; set; }

Time window in seconds.

property Routes #

public Dictionary<string, RouteLimitsConfig> Routes { get; set; }

Per-route overrides (best match wins).

property Rules #

public List<RateLimitRule> Rules { get; set; }

Multi-rule configuration (preferred). When specified, takes precedence over the single-window fields.

method GetEffectiveRules() #

public IReadOnlyList<RateLimitRule> GetEffectiveRules()

The rules in effect: rules when it has any; otherwise a long rule from per_seconds and max_requests and a burst rule from the burst settings, each when both values are set.

Returns

The rules in effect.

method Validate(string) #

public void Validate(string path)

Validate configuration.

class RateLimitConfig

public sealed class RateLimitConfig

Root configuration for Router rate limiting.

Members

MemberKindSummary
RateLimitConfig()constructorCreates an instance of RateLimitConfig.
ActivationThresholdPer5MinpropertyActivation gate: only check Valkey when traffic exceeds this threshold per 5 minutes.
ForEnvironmentpropertyEnvironment-level rate limits (Valkey-backed, across all router instances).
ForInstancepropertyInstance-level rate limits (in-memory, per router instance).
IsEnabledpropertyWhether rate limiting is enabled (at least one scope configured).
Load(IConfiguration)methodLoad configuration from IConfiguration.
Validate()methodValidate configuration values.

constructor RateLimitConfig() #

public RateLimitConfig()

Creates an instance of RateLimitConfig.

property ActivationThresholdPer5Min #

public int ActivationThresholdPer5Min { get; set; }

Activation gate: only check Valkey when traffic exceeds this threshold per 5 minutes. Set to 0 to always check Valkey. Default: 5000.

property ForEnvironment #

public EnvironmentLimitsConfig? ForEnvironment { get; set; }

Environment-level rate limits (Valkey-backed, across all router instances).

property ForInstance #

public InstanceLimitsConfig? ForInstance { get; set; }

Instance-level rate limits (in-memory, per router instance).

property IsEnabled #

public bool IsEnabled { get; }

Whether rate limiting is enabled (at least one scope configured).

method Load(IConfiguration) #

public static RateLimitConfig Load(IConfiguration configuration)

Load configuration from IConfiguration.

method Validate() #

public RateLimitConfig Validate()

Validate configuration values.

record RateLimitDecision

public sealed record RateLimitDecision

Result of a rate limit check.

Parameters

  • Allowed: Whether the request is allowed.
  • RetryAfterSeconds: Seconds to wait before retrying (if not allowed).
  • Scope: Which scope triggered the limit (instance or environment).
  • CurrentCount: Current request count in the window.
  • Limit: The limit that was applied.
  • WindowSeconds: The window size in seconds.
  • Microservice: The microservice that was checked.

Members

MemberKindSummary
RateLimitDecision(bool, int, RateLimitScope, long, long, int, string)constructorResult of a rate limit check.
AllowedpropertyWhether the request is allowed.
CurrentCountpropertyCurrent request count in the window.
LimitpropertyThe limit that was applied.
MicroservicepropertyThe microservice that was checked.
RetryAfterSecondspropertySeconds to wait before retrying (if not allowed).
RetryAtpropertyTime remaining until the window resets.
ScopepropertyWhich scope triggered the limit (instance or environment).
WindowSecondspropertyThe window size in seconds.
Allow(RateLimitScope, long, long, int, string)methodCreate an “allowed” decision.
Deny(RateLimitScope, int, long, long, int, string)methodCreate a “denied” decision.

constructor RateLimitDecision(bool, int, RateLimitScope, long, long, int, string) #

public RateLimitDecision(bool Allowed, int RetryAfterSeconds, RateLimitScope Scope, long CurrentCount, long Limit, int WindowSeconds, string? Microservice = null)

Result of a rate limit check.

Parameters

  • Allowed: Whether the request is allowed.
  • RetryAfterSeconds: Seconds to wait before retrying (if not allowed).
  • Scope: Which scope triggered the limit (instance or environment).
  • CurrentCount: Current request count in the window.
  • Limit: The limit that was applied.
  • WindowSeconds: The window size in seconds.
  • Microservice: The microservice that was checked.

property Allowed #

public bool Allowed { get; init; }

Whether the request is allowed.

property CurrentCount #

public long CurrentCount { get; init; }

Current request count in the window.

property Limit #

public long Limit { get; init; }

The limit that was applied.

property Microservice #

public string? Microservice { get; init; }

The microservice that was checked.

property RetryAfterSeconds #

public int RetryAfterSeconds { get; init; }

Seconds to wait before retrying (if not allowed).

property RetryAt #

public DateTimeOffset RetryAt { get; }

Time remaining until the window resets.

property Scope #

public RateLimitScope Scope { get; init; }

Which scope triggered the limit (instance or environment).

property WindowSeconds #

public int WindowSeconds { get; init; }

The window size in seconds.

method Allow(RateLimitScope, long, long, int, string) #

public static RateLimitDecision Allow(RateLimitScope scope, long currentCount, long limit, int windowSeconds, string? microservice = null)

Create an “allowed” decision.

method Deny(RateLimitScope, int, long, long, int, string) #

public static RateLimitDecision Deny(RateLimitScope scope, int retryAfterSeconds, long currentCount, long limit, int windowSeconds, string? microservice = null)

Create a “denied” decision.

class RateLimitMetrics

public static class RateLimitMetrics

OpenTelemetry metrics for Router rate limiting.

Members

MemberKindSummary
MeasureLatency(RateLimitScope)methodMeasure check latency with a disposable scope.
RecordCircuitBreakerTrip(string)methodRecord a circuit breaker trip.
RecordDecision(RateLimitScope, string, bool)methodRecord a rate limit decision.
RecordDecision(RateLimitScope, string, string, bool)methodRecord a rate limit decision with optional route tag.
RecordLatency(RateLimitScope, double)methodRecord check latency.
RecordRejection(RateLimitScope, string)methodRecord a rate limit rejection.
RecordValkeyError(string)methodRecord a Valkey error.
UpdateEnvironmentCount(long)methodUpdate current environment count gauge.
UpdateInstanceCount(long)methodUpdate current instance count gauge.

method MeasureLatency(RateLimitScope) #

public static IDisposable MeasureLatency(RateLimitScope scope)

Measure check latency with a disposable scope.

method RecordCircuitBreakerTrip(string) #

public static void RecordCircuitBreakerTrip(string reason)

Record a circuit breaker trip.

method RecordDecision(RateLimitScope, string, bool) #

public static void RecordDecision(RateLimitScope scope, string microservice, bool allowed)

Record a rate limit decision.

method RecordDecision(RateLimitScope, string, string, bool) #

public static void RecordDecision(RateLimitScope scope, string microservice, string? routeName, bool allowed)

Record a rate limit decision with optional route tag.

method RecordLatency(RateLimitScope, double) #

public static void RecordLatency(RateLimitScope scope, double milliseconds)

Record check latency.

method RecordRejection(RateLimitScope, string) #

public static void RecordRejection(RateLimitScope scope, string microservice)

Record a rate limit rejection.

method RecordValkeyError(string) #

public static void RecordValkeyError(string errorType)

Record a Valkey error.

method UpdateEnvironmentCount(long) #

public static void UpdateEnvironmentCount(long count)

Update current environment count gauge.

method UpdateInstanceCount(long) #

public static void UpdateInstanceCount(long count)

Update current instance count gauge.

class RateLimitMiddleware

public sealed class RateLimitMiddleware

Middleware that enforces rate limits on incoming requests. Returns 429 Too Many Requests with Retry-After header when limits are exceeded.

Members

MemberKindSummary
RateLimitMiddleware(RequestDelegate, RateLimitService, ILogger<RateLimitMiddleware>)constructorCreates the middleware.
InvokeAsync(HttpContext)methodChecks the rate limits of the request and answers 429 when a limit is exceeded.

constructor RateLimitMiddleware(RequestDelegate, RateLimitService, ILogger<RateLimitMiddleware>) #

public RateLimitMiddleware(RequestDelegate next, RateLimitService rateLimitService, ILogger<RateLimitMiddleware> logger)

Creates the middleware.

Parameters

  • next: The next middleware.
  • rateLimitService: Checks the limits.
  • logger: Receives the diagnostics.

method InvokeAsync(HttpContext) #

public Task InvokeAsync(HttpContext context)

Checks the rate limits of the request and answers 429 when a limit is exceeded.

Parameters

  • context: The HTTP context.

Returns

A task that completes when the request is handled.

class RateLimitRule

public sealed class RateLimitRule

A single rate limit rule (window + max requests).

Members

MemberKindSummary
RateLimitRule()constructorCreates an instance of RateLimitRule.
MaxRequestspropertyThe requests allowed in the window; positive (max_requests).
NamepropertyThe rule name, for diagnostics (name).
PerSecondspropertyThe window, in seconds; positive (per_seconds).
Validate(string)methodValidates the rule.

constructor RateLimitRule() #

public RateLimitRule()

Creates an instance of RateLimitRule.

property MaxRequests #

public int MaxRequests { get; set; }

The requests allowed in the window; positive (max_requests).

property Name #

public string? Name { get; set; }

The rule name, for diagnostics (name).

property PerSeconds #

public int PerSeconds { get; set; }

The window, in seconds; positive (per_seconds).

method Validate(string) #

public void Validate(string path)

Validates the rule.

Parameters

  • path: The configuration path, for messages.

Exceptions

  • ArgumentException: A value is not positive.

enum RateLimitScope

public enum RateLimitScope

Rate limit scope.

ValueDescription
Instance = 0Instance-level (in-memory).
Environment = 1Environment-level (Valkey-backed).

class RateLimitService

public sealed class RateLimitService

Service that orchestrates rate limit checks across instance and environment scopes.

Members

MemberKindSummary
RateLimitService(RateLimitConfig, InstanceRateLimiter, EnvironmentRateLimiter, ILogger<RateLimitService>)constructorCreates the service.
CheckLimitAsync(string, string, string, CancellationToken)methodCheck rate limits for a request.

constructor RateLimitService(RateLimitConfig, InstanceRateLimiter, EnvironmentRateLimiter, ILogger<RateLimitService>) #

public RateLimitService(RateLimitConfig config, InstanceRateLimiter? instanceLimiter, EnvironmentRateLimiter? environmentLimiter, ILogger<RateLimitService> logger)

Creates the service.

Parameters

  • config: The rate limit configuration.
  • instanceLimiter: The process-local limiter, when instance limits are set.
  • environmentLimiter: The shared limiter, when environment limits are set.
  • logger: Receives the diagnostics.

method CheckLimitAsync(string, string, string, CancellationToken) #

public Task<RateLimitDecision> CheckLimitAsync(string? microservice, string? requestPath, string? tenant, CancellationToken cancellationToken)

Check rate limits for a request.

Parameters

  • microservice: Target microservice.
  • requestPath: HTTP request path.
  • tenant: The caller’s tenant (the stellaops:tenant claim), or null. Each tenant has its own counters; the service and route overrides and the metrics do not depend on it.
  • cancellationToken: Cancellation token.

Returns

Decision indicating whether request is allowed.

class RateLimitServiceCollectionExtensions

public static class RateLimitServiceCollectionExtensions

Extension methods for registering rate limiting services.

Members

MemberKindSummary
AddRouterRateLimiting(IServiceCollection, IConfiguration)extension methodAdds rate limiting services to the DI container.
AddRouterRateLimiting<TStore>(IServiceCollection, IConfiguration)extension methodAdds rate limiting with a custom store for the environment rate limit.

extension method AddRouterRateLimiting(IServiceCollection, IConfiguration) #

public static IServiceCollection AddRouterRateLimiting(this IServiceCollection services, IConfiguration configuration)

Adds rate limiting services to the DI container.

Parameters

  • services: The service collection.
  • configuration: The configuration.

Returns

The service collection for chaining.

extension method AddRouterRateLimiting<TStore>(IServiceCollection, IConfiguration) #

public static IServiceCollection AddRouterRateLimiting<TStore>(this IServiceCollection services, IConfiguration configuration) where TStore : class, IValkeyRateLimitStore

Adds rate limiting with a custom store for the environment rate limit.

Type parameters

  • TStore: The store implementation.

Parameters

  • services: The service collection.
  • configuration: The configuration.

Returns

The service collection for chaining.

record RateLimitStoreResult

public sealed record RateLimitStoreResult

Result of a Valkey rate limit check.

Parameters

  • Allowed: Whether the request is allowed.
  • CurrentCount: The count in the window, this request included.
  • Limit: The requests allowed in the window.
  • WindowSeconds: The window, in seconds.
  • RetryAfterSeconds: When the request may be retried, in seconds; 0 when it is allowed.

Members

MemberKindSummary
RateLimitStoreResult(bool, long, int, int, int)constructorResult of a Valkey rate limit check.
AllowedpropertyWhether the request is allowed.
CurrentCountpropertyThe count in the window, this request included.
LimitpropertyThe requests allowed in the window.
RetryAfterSecondspropertyWhen the request may be retried, in seconds; 0 when it is allowed.
WindowSecondspropertyThe window, in seconds.

constructor RateLimitStoreResult(bool, long, int, int, int) #

public RateLimitStoreResult(bool Allowed, long CurrentCount, int Limit, int WindowSeconds, int RetryAfterSeconds)

Result of a Valkey rate limit check.

Parameters

  • Allowed: Whether the request is allowed.
  • CurrentCount: The count in the window, this request included.
  • Limit: The requests allowed in the window.
  • WindowSeconds: The window, in seconds.
  • RetryAfterSeconds: When the request may be retried, in seconds; 0 when it is allowed.

property Allowed #

public bool Allowed { get; init; }

Whether the request is allowed.

property CurrentCount #

public long CurrentCount { get; init; }

The count in the window, this request included.

property Limit #

public int Limit { get; init; }

The requests allowed in the window.

property RetryAfterSeconds #

public int RetryAfterSeconds { get; init; }

When the request may be retried, in seconds; 0 when it is allowed.

property WindowSeconds #

public int WindowSeconds { get; init; }

The window, in seconds.

class RouteLimitsConfig

public sealed class RouteLimitsConfig

Per-route rate limit configuration.

Members

MemberKindSummary
RouteLimitsConfig()constructorCreates an instance of RouteLimitsConfig.
AllowBurstForSecondspropertyThe window of the burst limit, in seconds (allow_burst_for_seconds).
AllowMaxBurstRequestspropertyThe requests allowed in the burst window (allow_max_burst_requests).
MatchTypepropertyHow RouteLimitsConfig.Patternmatches a path.
MaxRequestspropertyThe requests allowed in the window (max_requests).
PatternpropertyRoute pattern: exact (“/api/scans”), prefix (“/api/scans/*”), or regex (“^/api/scans/[a-f0-9-]+$”).
PerSecondspropertyThe window of the single-window limit, in seconds (per_seconds).
RulespropertyMulti-rule configuration (preferred).
GetEffectiveRules()methodThe rules in effect: rules when it has any; otherwise a long rule from per_seconds and max_requests and a burst rule from the burst settings, each when both values are set.
Validate(string)methodValidates the route limits and compiles a regex pattern.

constructor RouteLimitsConfig() #

public RouteLimitsConfig()

Creates an instance of RouteLimitsConfig.

property AllowBurstForSeconds #

public int? AllowBurstForSeconds { get; set; }

The window of the burst limit, in seconds (allow_burst_for_seconds).

property AllowMaxBurstRequests #

public int? AllowMaxBurstRequests { get; set; }

The requests allowed in the burst window (allow_max_burst_requests).

property MatchType #

public RouteMatchType MatchType { get; set; }

How RouteLimitsConfig.Patternmatches a path. The default is RouteMatchType.Exact.

property MaxRequests #

public int? MaxRequests { get; set; }

The requests allowed in the window (max_requests).

property Pattern #

public string Pattern { get; set; }

Route pattern: exact (“/api/scans”), prefix (“/api/scans/*”), or regex (“^/api/scans/[a-f0-9-]+$”).

property PerSeconds #

public int? PerSeconds { get; set; }

The window of the single-window limit, in seconds (per_seconds).

property Rules #

public List<RateLimitRule> Rules { get; set; }

Multi-rule configuration (preferred). When specified, takes precedence over the single-window fields.

method GetEffectiveRules() #

public IReadOnlyList<RateLimitRule> GetEffectiveRules()

The rules in effect: rules when it has any; otherwise a long rule from per_seconds and max_requests and a burst rule from the burst settings, each when both values are set.

Returns

The rules in effect.

method Validate(string) #

public void Validate(string path)

Validates the route limits and compiles a regex pattern.

Parameters

  • path: The configuration path, for messages.

Exceptions

  • ArgumentException: A setting is missing or invalid.

enum RouteMatchType

public enum RouteMatchType

How a route rate limit pattern matches a request path.

ValueDescription
Exact = 0The path equals the pattern.
Prefix = 1The path starts with the pattern.
Regex = 2The path matches the pattern as a regular expression, ignoring case.

namespace StellaOps.Router.Gateway.Services

TypeKindDescription
IRekorSubmissionServiceinterfaceService for submitting DSSE envelopes to Rekor.
IRouterGatewayLocalHarnessTransportinterfaceGateway-side adapter for process-local development and test transports.
IRoutingWeightOverrideStoreinterfaceProcess-local routing weight overrides used for live canary tuning.
InMemoryRoutingWeightOverrideStoreclassThread-safe in-memory implementation of IRoutingWeightOverrideStore.
RekorLinkagerecordRekor linkage record.
RekorSubmissionOptionsclassConfiguration for Rekor submission.
RekorSubmissionResultrecordRekor submission result.
RekorSubmissionServiceclassDefault implementation of Rekor submission service.
RoutingWeightOverriderecordOne service/version or service/version/instance routing weight override.
RoutingWeightResolutionrecordEffective routing weight plus the source that supplied it.

interface IRekorSubmissionService

public interface IRekorSubmissionService

Service for submitting DSSE envelopes to Rekor.

Members

MemberKindSummary
GetLinkageAsync(string, CancellationToken)methodGets the Rekor linkage for a digest.
QueueForSubmission(string, byte[])methodQueues a DSSE envelope for async submission.
SubmitDsseAsync(string, byte[], CancellationToken)methodSubmits a DSSE envelope to Rekor.

method GetLinkageAsync(string, CancellationToken) #

Task<RekorLinkage?> GetLinkageAsync(string digest, CancellationToken ct = default)

Gets the Rekor linkage for a digest.

method QueueForSubmission(string, byte[]) #

void QueueForSubmission(string digest, byte[] dsseEnvelope)

Queues a DSSE envelope for async submission.

method SubmitDsseAsync(string, byte[], CancellationToken) #

Task<RekorSubmissionResult> SubmitDsseAsync(string digest, byte[] dsseEnvelope, CancellationToken ct = default)

Submits a DSSE envelope to Rekor.

interface IRouterGatewayLocalHarnessTransport

public interface IRouterGatewayLocalHarnessTransport : ITransportServer

Gateway-side adapter for process-local development and test transports.

Members

MemberKindSummary
OnConnectionClosedeventRaised when a local connection closes, with its identifier.
OnHeartbeatReceivedeventRaised for each heartbeat of a local microservice.
OnHelloReceivedeventRaised when a local microservice announces itself and its endpoints (a HELLO).
RemoveConnection(string)methodRemoves a connection.
StartListeningToConnection(string)methodStarts reading the frames of a connection.

event OnConnectionClosed #

event Func<string, Task>? OnConnectionClosed

Raised when a local connection closes, with its identifier.

event OnHeartbeatReceived #

event Func<ConnectionState, HeartbeatPayload, Task>? OnHeartbeatReceived

Raised for each heartbeat of a local microservice.

event OnHelloReceived #

event Func<ConnectionState, HelloPayload, Task>? OnHelloReceived

Raised when a local microservice announces itself and its endpoints (a HELLO).

method RemoveConnection(string) #

bool RemoveConnection(string connectionId)

Removes a connection.

Parameters

  • connectionId: The connection identifier.

Returns

true when the connection existed.

method StartListeningToConnection(string) #

void StartListeningToConnection(string connectionId)

Starts reading the frames of a connection.

Parameters

  • connectionId: The connection identifier.

interface IRoutingWeightOverrideStore

public interface IRoutingWeightOverrideStore

Process-local routing weight overrides used for live canary tuning.

Members

MemberKindSummary
MaxWeightpropertyGets the maximum accepted runtime override weight.
GetOverrides()methodGets the current runtime and startup-configured overrides.
Resolve(ConnectionState)methodResolves the effective weight for a live connection.
Upsert(RoutingWeightOverride)methodAdds or replaces one routing weight override.

property MaxWeight #

int MaxWeight { get; }

Gets the maximum accepted runtime override weight.

method GetOverrides() #

IReadOnlyList<RoutingWeightOverride> GetOverrides()

Gets the current runtime and startup-configured overrides.

method Resolve(ConnectionState) #

RoutingWeightResolution Resolve(ConnectionState connection)

Resolves the effective weight for a live connection.

method Upsert(RoutingWeightOverride) #

RoutingWeightOverride Upsert(RoutingWeightOverride weightOverride)

Adds or replaces one routing weight override.

class InMemoryRoutingWeightOverrideStore

public sealed class InMemoryRoutingWeightOverrideStore : IRoutingWeightOverrideStore

Thread-safe in-memory implementation of IRoutingWeightOverrideStore.

Members

MemberKindSummary
InMemoryRoutingWeightOverrideStore(IOptions<RoutingOptions>)constructorCreates the store with the overrides the routing options configure at startup.
MaxWeightpropertyGets the maximum accepted runtime override weight.
GetOverrides()methodGets the current runtime and startup-configured overrides.
Resolve(ConnectionState)methodResolves the effective weight for a live connection.
Upsert(RoutingWeightOverride)methodAdds or replaces one routing weight override.

constructor InMemoryRoutingWeightOverrideStore(IOptions<RoutingOptions>) #

public InMemoryRoutingWeightOverrideStore(IOptions<RoutingOptions> options)

Creates the store with the overrides the routing options configure at startup.

Parameters

  • options: The routing options.

property MaxWeight #

public int MaxWeight { get; }

Gets the maximum accepted runtime override weight.

method GetOverrides() #

public IReadOnlyList<RoutingWeightOverride> GetOverrides()

Gets the current runtime and startup-configured overrides.

method Resolve(ConnectionState) #

public RoutingWeightResolution Resolve(ConnectionState connection)

Resolves the effective weight for a live connection.

method Upsert(RoutingWeightOverride) #

public RoutingWeightOverride Upsert(RoutingWeightOverride weightOverride)

Adds or replaces one routing weight override.

record RekorLinkage

public sealed record RekorLinkage

Rekor linkage record.

Members

MemberKindSummary
RekorLinkage()constructorCreates an instance of RekorLinkage.
CreatedAtpropertyWhen this linkage was created.
DigestpropertyArtifact digest.
EnvelopeHashpropertyDSSE envelope hash.
IntegratedAtpropertyWhen the entry was integrated.
LogIndexpropertyRekor log index.
RekorUuidpropertyRekor UUID.

constructor RekorLinkage() #

public RekorLinkage()

Creates an instance of RekorLinkage.

property CreatedAt #

public DateTimeOffset CreatedAt { get; init; }

When this linkage was created.

property Digest #

public required string Digest { get; init; }

Artifact digest.

property EnvelopeHash #

public required string EnvelopeHash { get; init; }

DSSE envelope hash.

property IntegratedAt #

public DateTimeOffset IntegratedAt { get; init; }

When the entry was integrated.

property LogIndex #

public long LogIndex { get; init; }

Rekor log index.

property RekorUuid #

public required string RekorUuid { get; init; }

Rekor UUID.

class RekorSubmissionOptions

public sealed class RekorSubmissionOptions

Configuration for Rekor submission.

Members

MemberKindSummary
RekorSubmissionOptions()constructorCreates an instance of RekorSubmissionOptions.
AsyncSubmissionpropertyWhether to submit asynchronously (don’t block push).
CacheLinkagepropertyCache Rekor linkage results.
CacheTtlSecondspropertyCache TTL in seconds.
RekorUrlpropertyRekor instance URL.
RetryAttemptspropertyNumber of retry attempts.
SubmitToRekorpropertyWhether to submit attestations to Rekor.
TimeoutSecondspropertyTimeout for Rekor submission in seconds.

constructor RekorSubmissionOptions() #

public RekorSubmissionOptions()

Creates an instance of RekorSubmissionOptions.

property AsyncSubmission #

public bool AsyncSubmission { get; set; }

Whether to submit asynchronously (don’t block push).

property CacheLinkage #

public bool CacheLinkage { get; set; }

Cache Rekor linkage results.

property CacheTtlSeconds #

public int CacheTtlSeconds { get; set; }

Cache TTL in seconds.

property RekorUrl #

public string RekorUrl { get; set; }

Rekor instance URL.

property RetryAttempts #

public int RetryAttempts { get; set; }

Number of retry attempts.

property SubmitToRekor #

public bool SubmitToRekor { get; set; }

Whether to submit attestations to Rekor.

property TimeoutSeconds #

public int TimeoutSeconds { get; set; }

Timeout for Rekor submission in seconds.

record RekorSubmissionResult

public sealed record RekorSubmissionResult

Rekor submission result.

Members

MemberKindSummary
RekorSubmissionResult()constructorCreates an instance of RekorSubmissionResult.
ErrorpropertyError message if failed.
IntegratedAtpropertyIntegrated timestamp.
LogIndexpropertyRekor log index.
SuccesspropertyWhether submission was successful.
UuidpropertyRekor entry UUID.

constructor RekorSubmissionResult() #

public RekorSubmissionResult()

Creates an instance of RekorSubmissionResult.

property Error #

public string? Error { get; init; }

Error message if failed.

property IntegratedAt #

public DateTimeOffset? IntegratedAt { get; init; }

Integrated timestamp.

property LogIndex #

public long? LogIndex { get; init; }

Rekor log index.

property Success #

public bool Success { get; init; }

Whether submission was successful.

property Uuid #

public string? Uuid { get; init; }

Rekor entry UUID.

class RekorSubmissionService

public sealed class RekorSubmissionService : IRekorSubmissionService, IDisposable

Default implementation of Rekor submission service.

Members

MemberKindSummary
RekorSubmissionService(HttpClient, IMemoryCache, IOptions<RekorSubmissionOptions>, ILogger<RekorSubmissionService>)constructorCreates the service.
Dispose()methodReleases the service.
GetLinkageAsync(string, CancellationToken)methodGets the Rekor linkage for a digest.
QueueForSubmission(string, byte[])methodQueues a DSSE envelope for async submission.
SubmitDsseAsync(string, byte[], CancellationToken)methodSubmits a DSSE envelope to Rekor.

constructor RekorSubmissionService(HttpClient, IMemoryCache, IOptions<RekorSubmissionOptions>, ILogger<RekorSubmissionService>) #

public RekorSubmissionService(HttpClient httpClient, IMemoryCache cache, IOptions<RekorSubmissionOptions> options, ILogger<RekorSubmissionService> logger)

Creates the service.

Parameters

  • httpClient: The client that calls the transparency log.
  • cache: Caches the linkages.
  • options: The transparency log settings.
  • logger: Receives the diagnostics.

method Dispose() #

public void Dispose()

Releases the service.

method GetLinkageAsync(string, CancellationToken) #

public Task<RekorLinkage?> GetLinkageAsync(string digest, CancellationToken ct = default)

Gets the Rekor linkage for a digest.

method QueueForSubmission(string, byte[]) #

public void QueueForSubmission(string digest, byte[] dsseEnvelope)

Queues a DSSE envelope for async submission.

method SubmitDsseAsync(string, byte[], CancellationToken) #

public Task<RekorSubmissionResult> SubmitDsseAsync(string digest, byte[] dsseEnvelope, CancellationToken ct = default)

Submits a DSSE envelope to Rekor.

record RoutingWeightOverride

public sealed record RoutingWeightOverride

One service/version or service/version/instance routing weight override.

Parameters

  • Service: The service.
  • Version: The service version.
  • InstanceId: The instance; the override applies to the whole version when not set.
  • Weight: The routing weight.

Members

MemberKindSummary
RoutingWeightOverride(string, string, string, int)constructorOne service/version or service/version/instance routing weight override.
InstanceIdpropertyThe instance; the override applies to the whole version when not set.
ServicepropertyThe service.
VersionpropertyThe service version.
WeightpropertyThe routing weight.

constructor RoutingWeightOverride(string, string, string, int) #

public RoutingWeightOverride(string Service, string Version, string? InstanceId, int Weight)

One service/version or service/version/instance routing weight override.

Parameters

  • Service: The service.
  • Version: The service version.
  • InstanceId: The instance; the override applies to the whole version when not set.
  • Weight: The routing weight.

property InstanceId #

public string? InstanceId { get; init; }

The instance; the override applies to the whole version when not set.

property Service #

public string Service { get; init; }

The service.

property Version #

public string Version { get; init; }

The service version.

property Weight #

public int Weight { get; init; }

The routing weight.

record RoutingWeightResolution

public sealed record RoutingWeightResolution

Effective routing weight plus the source that supplied it.

Parameters

  • Weight: The effective weight.
  • Source: Where the weight comes from: instanceOverride, versionOverride or instance (the weight the instance announced).

Members

MemberKindSummary
RoutingWeightResolution(int, string)constructorEffective routing weight plus the source that supplied it.
SourcepropertyWhere the weight comes from: instanceOverride, versionOverride or instance (the weight the instance announced).
WeightpropertyThe effective weight.

constructor RoutingWeightResolution(int, string) #

public RoutingWeightResolution(int Weight, string Source)

Effective routing weight plus the source that supplied it.

Parameters

  • Weight: The effective weight.
  • Source: Where the weight comes from: instanceOverride, versionOverride or instance (the weight the instance announced).

property Source #

public string Source { get; init; }

Where the weight comes from: instanceOverride, versionOverride or instance (the weight the instance announced).

property Weight #

public int Weight { get; init; }

The effective weight.