StellaOps.Microservice
Microservice SDK for the Router: registers the endpoints of a service, connects it to a gateway over a Router transport and dispatches the requests it receives. Install Installing Stella Ops packagesRouter downloads and signaturesnet10.01.0.1-20261117T070237Zdotnet add package StellaOps.
Namespaces
| Namespace | Types |
|---|---|
StellaOps. | 39 |
StellaOps. | 4 |
StellaOps. | 3 |
StellaOps. | 10 |
namespace StellaOps.Microservice
| Type | Kind | Description |
|---|---|---|
ClaimRequirementConfig | class | Configuration for a claim requirement. |
EndpointDiscoveryService | class | Service that discovers endpoints and applies YAML configuration overrides. |
EndpointMatch | class | Represents a matched endpoint with extracted path parameters. |
EndpointOverrideConfig | class | Configuration for overriding an endpoint’s properties. |
EndpointOverrideMerger | class | Merges endpoint overrides from YAML configuration with code defaults. |
EndpointRegistry | class | Default implementation of endpoint registry using path matchers. |
GeneratedEndpointDiscoveryProvider | class | Discovers endpoints using source-generated provider, falling back to reflection. |
HeaderCollection | class | Default implementation of header collection. |
IEndpointDiscoveryProvider | interface | Provides endpoint discovery functionality. |
IEndpointDiscoveryService | interface | Interface for discovering endpoints with YAML configuration support. |
IEndpointOverrideMerger | interface | Interface for merging endpoint overrides from YAML configuration. |
IEndpointRegistry | interface | Registry for looking up endpoint handlers by method and path. |
IEndpointSchemaDefinitionProvider | interface | Optional provider for endpoint JSON schema definitions discovered at runtime. |
IGeneratedEndpointProvider | interface | Interface implemented by the source-generated endpoint provider. |
IHeaderCollection | interface | Abstraction for HTTP-style header collection. |
IMicroserviceYamlLoader | interface | Interface for loading microservice YAML configuration. |
IRawStellaEndpoint | interface | Interface for a raw Stella endpoint that handles requests with full context. |
IRequestDispatcher | interface | Abstraction for dispatching Router request frames to handlers. |
IRouterConnectionManager | interface | Manages connections to router gateways. |
IStellaEndpoint | interface | Marker interface for all Stella endpoints. |
IStellaEndpoint< | interface | Interface for a typed Stella endpoint with request and response. |
IStellaEndpoint< | interface | Interface for a typed Stella endpoint with response only (no request body). |
InflightRequestTracker | class | Tracks in-flight requests and manages their cancellation tokens. |
MicroserviceHostedService | class | Hosted service that manages the microservice lifecycle. |
MicroserviceServiceCollectionExtensions | class | Extension methods for registering Stella microservice services. |
MicroserviceYamlConfig | class | Root configuration for microservice endpoint overrides loaded from YAML. |
MicroserviceYamlLoader | class | Loads microservice configuration from a YAML file. |
RawRequestContext | class | Context for a raw request. |
RawResponse | class | Represents a raw response from an endpoint. |
ReflectionEndpointDiscoveryProvider | class | Discovers endpoints using runtime reflection. |
RequestDispatcher | class | Dispatches incoming REQUEST frames to the appropriate endpoint handlers. |
RouterConnectionManager | class | Manages connections to router gateways. |
RouterEndpointConfig | class | Configuration for a router endpoint. |
SchemaProviderDiscoveryDiagnostics | class | Captures schema provider discovery issues for startup diagnostics. |
SchemaProviderDiscoveryIssue | record | Represents a schema provider discovery issue. |
StellaEndpointAttribute | class | Marks a class as a Stella endpoint handler. |
StellaMicroserviceOptions | class | Options for configuring a Stella microservice. |
TypedEndpointAdapter | class | Adapts typed endpoint handlers to the raw endpoint interface. |
ValidateSchemaAttribute | class | Enables JSON Schema validation for this endpoint. |
class ClaimRequirementConfig
public sealed class ClaimRequirementConfig
Configuration for a claim requirement.
Members
| Member | Kind | Summary |
|---|---|---|
ClaimRequirementConfig( | constructor | Creates an instance of Claim. |
Type | property | Gets or sets the claim type. |
Value | property | Gets or sets the claim value. |
ToClaimRequirement( | method | Converts to a ClaimRequirement model. |
constructor ClaimRequirementConfig() #
ClaimRequirementConfig() #public ClaimRequirementConfig()
Creates an instance of Claim.
property Type #
Type #public string Type { get; set; }
Gets or sets the claim type.
property Value #
Value #public string? Value { get; set; }
Gets or sets the claim value.
method ToClaimRequirement() #
ToClaimRequirement() #public ClaimRequirement ToClaimRequirement()
Converts to a ClaimRequirement model.
class EndpointDiscoveryService
public sealed class EndpointDiscoveryService : IEndpointDiscoveryService
Service that discovers endpoints and applies YAML configuration overrides.
Members
| Member | Kind | Summary |
|---|---|---|
EndpointDiscoveryService( | constructor | Initializes a new instance of the EndpointDiscoveryServiceclass. |
DiscoverEndpoints( | method | Discovers all endpoints, applying any YAML configuration overrides. |
constructor EndpointDiscoveryService(IEndpointDiscoveryProvider, IMicroserviceYamlLoader, IEndpointOverrideMerger, ILogger<EndpointDiscoveryService>) #
EndpointDiscoveryService(IEndpointDiscoveryProvider, IMicroserviceYamlLoader, IEndpointOverrideMerger, ILogger<EndpointDiscoveryService>) #public EndpointDiscoveryService(IEndpointDiscoveryProvider discoveryProvider, IMicroserviceYamlLoader yamlLoader, IEndpointOverrideMerger merger, ILogger<EndpointDiscoveryService> logger)
Initializes a new instance of the EndpointDiscoveryServiceclass.
method DiscoverEndpoints() #
DiscoverEndpoints() #public IReadOnlyList<EndpointDescriptor> DiscoverEndpoints()
Discovers all endpoints, applying any YAML configuration overrides.
Returns
The discovered endpoints with overrides applied.
class EndpointMatch
public sealed class EndpointMatch
Represents a matched endpoint with extracted path parameters.
Members
| Member | Kind | Summary |
|---|---|---|
EndpointMatch( | constructor | Creates an instance of EndpointMatch. |
Endpoint | property | Gets the matched endpoint descriptor. |
PathParameters | property | Gets the path parameters extracted from the URL. |
constructor EndpointMatch() #
EndpointMatch() #public EndpointMatch()
Creates an instance of EndpointMatch.
property Endpoint #
Endpoint #public required EndpointDescriptor Endpoint { get; init; }
Gets the matched endpoint descriptor.
property PathParameters #
PathParameters #public required IReadOnlyDictionary<string, string> PathParameters { get; init; }
Gets the path parameters extracted from the URL.
class EndpointOverrideConfig
public sealed class EndpointOverrideConfig
Configuration for overriding an endpoint’s properties.
Members
| Member | Kind | Summary |
|---|---|---|
EndpointOverrideConfig( | constructor | Creates an instance of Endpoint. |
DefaultTimeout | property | Gets or sets the default timeout override. |
Method | property | Gets or sets the HTTP method to match. |
Path | property | Gets or sets the path to match. |
RequiringClaims | property | Gets or sets the claim requirements. |
SupportsStreaming | property | Gets or sets whether streaming is supported. |
GetDefaultTimeoutAsTimeSpan( | method | Parses the DefaultTimeout string to a TimeSpan. |
TryGetDefaultTimeoutAsTimeSpan( | method | Parses the DefaultTimeout string to a TimeSpan with error output. |
constructor EndpointOverrideConfig() #
EndpointOverrideConfig() #public EndpointOverrideConfig()
Creates an instance of Endpoint.
property DefaultTimeout #
DefaultTimeout #public string? DefaultTimeout { get; set; }
Gets or sets the default timeout override.
property Method #
Method #public string Method { get; set; }
Gets or sets the HTTP method to match.
property Path #
Path #public string Path { get; set; }
Gets or sets the path to match.
property RequiringClaims #
RequiringClaims #public List<ClaimRequirementConfig>? RequiringClaims { get; set; }
Gets or sets the claim requirements.
property SupportsStreaming #
SupportsStreaming #public bool? SupportsStreaming { get; set; }
Gets or sets whether streaming is supported.
method GetDefaultTimeoutAsTimeSpan() #
GetDefaultTimeoutAsTimeSpan() #public TimeSpan? GetDefaultTimeoutAsTimeSpan()
Parses the DefaultTimeout string to a TimeSpan.
method TryGetDefaultTimeoutAsTimeSpan(out TimeSpan, out string) #
TryGetDefaultTimeoutAsTimeSpan(out TimeSpan, out string) #public bool TryGetDefaultTimeoutAsTimeSpan(out TimeSpan timeout, out string? error)
Parses the DefaultTimeout string to a TimeSpan with error output.
class EndpointOverrideMerger
public sealed class EndpointOverrideMerger : IEndpointOverrideMerger
Merges endpoint overrides from YAML configuration with code defaults.
Members
| Member | Kind | Summary |
|---|---|---|
EndpointOverrideMerger( | constructor | Initializes a new instance of the EndpointOverrideMergerclass. |
Merge( | method | Merges YAML overrides with code-defined endpoints. |
constructor EndpointOverrideMerger(ILogger<EndpointOverrideMerger>) #
EndpointOverrideMerger(ILogger<EndpointOverrideMerger>) #public EndpointOverrideMerger(ILogger<EndpointOverrideMerger> logger)
Initializes a new instance of the EndpointOverrideMergerclass.
method Merge(IReadOnlyList<EndpointDescriptor>, MicroserviceYamlConfig) #
Merge(IReadOnlyList<EndpointDescriptor>, MicroserviceYamlConfig) #public IReadOnlyList<EndpointDescriptor> Merge(IReadOnlyList<EndpointDescriptor> codeEndpoints, MicroserviceYamlConfig? yamlConfig)
Merges YAML overrides with code-defined endpoints.
Parameters
codeEndpoints: The endpoints discovered from code.yamlConfig: The YAML configuration, if any.
Returns
The merged endpoints.
class EndpointRegistry
public sealed class EndpointRegistry : IEndpointRegistry
Default implementation of endpoint registry using path matchers.
Members
| Member | Kind | Summary |
|---|---|---|
EndpointRegistry( | constructor | Initializes a new instance of the EndpointRegistryclass. |
GetAllEndpoints( | method | Gets all registered endpoints. |
Register( | method | Registers an endpoint descriptor. |
RegisterAll( | method | Registers multiple endpoint descriptors. |
TryMatch( | method | Tries to find a matching endpoint for the given method and path. |
constructor EndpointRegistry(bool) #
EndpointRegistry(bool) #public EndpointRegistry(bool caseInsensitive = true)
Initializes a new instance of the EndpointRegistryclass.
Parameters
caseInsensitive: Whether path matching should be case-insensitive.
method GetAllEndpoints() #
GetAllEndpoints() #public IReadOnlyList<EndpointDescriptor> GetAllEndpoints()
Gets all registered endpoints.
Returns
All registered endpoint descriptors.
method Register(EndpointDescriptor) #
Register(EndpointDescriptor) #public void Register(EndpointDescriptor endpoint)
Registers an endpoint descriptor.
Parameters
endpoint: The endpoint descriptor to register.
method RegisterAll(IEnumerable<EndpointDescriptor>) #
RegisterAll(IEnumerable<EndpointDescriptor>) #public void RegisterAll(IEnumerable<EndpointDescriptor> endpoints)
Registers multiple endpoint descriptors.
Parameters
endpoints: The endpoint descriptors to register.
method TryMatch(string, string, out EndpointMatch) #
TryMatch(string, string, out EndpointMatch) #public bool TryMatch(string method, string path, out EndpointMatch? match)
Tries to find a matching endpoint for the given method and path.
Parameters
method: The HTTP method.path: The request path.match: The matching endpoint information if found.
Returns
True if a matching endpoint was found.
class GeneratedEndpointDiscoveryProvider
public sealed class GeneratedEndpointDiscoveryProvider : IEndpointDiscoveryProvider, IEndpointSchemaDefinitionProvider
Discovers endpoints using source-generated provider, falling back to reflection. The schema definitions come from the same generated provider as the endpoints, so an endpoint that names a generated schema (ValidateSchemaAttribute) is sent to the gateway together with that schema.
Members
| Member | Kind | Summary |
|---|---|---|
GeneratedEndpointDiscoveryProvider( | constructor | Initializes a new instance of the GeneratedEndpointDiscoveryProviderclass. |
DiscoverEndpoints( | method | Discovers all endpoints in the application. |
DiscoverSchemaDefinitions( | method | Gets schema definitions keyed by schema identifier. |
constructor GeneratedEndpointDiscoveryProvider(StellaMicroserviceOptions, ILogger<GeneratedEndpointDiscoveryProvider>, IServiceProviderIsService) #
GeneratedEndpointDiscoveryProvider(StellaMicroserviceOptions, ILogger<GeneratedEndpointDiscoveryProvider>, IServiceProviderIsService) #public GeneratedEndpointDiscoveryProvider(StellaMicroserviceOptions options, ILogger<GeneratedEndpointDiscoveryProvider> logger, IServiceProviderIsService? serviceProviderIsService = null)
Initializes a new instance of the GeneratedEndpointDiscoveryProviderclass.
method DiscoverEndpoints() #
DiscoverEndpoints() #public IReadOnlyList<EndpointDescriptor> DiscoverEndpoints()
Discovers all endpoints in the application.
Returns
The discovered endpoints.
method DiscoverSchemaDefinitions() #
DiscoverSchemaDefinitions() #public IReadOnlyDictionary<string, SchemaDefinition> DiscoverSchemaDefinitions()
Gets schema definitions keyed by schema identifier.
Remarks
Returns the schemas of the generated provider that GeneratedEndpointDiscoveryProvider.uses, or none when discovery falls back to reflection (reflection discovery names no schemas).
class HeaderCollection
public sealed class HeaderCollection : IHeaderCollection
Default implementation of header collection.
Members
| Member | Kind | Summary |
|---|---|---|
HeaderCollection( | constructor | Initializes a new instance of the HeaderCollectionclass. |
HeaderCollection( | constructor | Initializes a new instance from key-value pairs. |
Empty | field | Gets an empty header collection. |
this[string] | indexer | Gets a header value by key. |
Add( | method | Adds a header value. |
ContainsKey( | method | Checks if a header exists. |
GetEnumerator( | method | See IEnumerable<. |
GetValues( | method | Gets all values for a header key. |
Set( | method | Sets a header, replacing any existing values. |
TryGetValue( | method | Tries to get a header value. |
constructor HeaderCollection() #
HeaderCollection() #public HeaderCollection()
Initializes a new instance of the HeaderCollectionclass.
constructor HeaderCollection(IEnumerable<KeyValuePair<string, string>>) #
HeaderCollection(IEnumerable<KeyValuePair<string, string>>) #public HeaderCollection(IEnumerable<KeyValuePair<string, string>> headers)
Initializes a new instance from key-value pairs.
field Empty #
Empty #public static readonly HeaderCollection Empty
Gets an empty header collection.
indexer this[string] #
this[string] #public string? this[string key] { get; }
Gets a header value by key.
Parameters
key: The header key (case-insensitive).
Returns
The header value, or null if not found.
method Add(string, string) #
Add(string, string) #public void Add(string key, string value)
Adds a header value.
Parameters
key: The header key.value: The header value.
method ContainsKey(string) #
ContainsKey(string) #public bool ContainsKey(string key)
Checks if a header exists.
Parameters
key: The header key.
Returns
True if the header exists.
method GetEnumerator() #
GetEnumerator() #public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
See IEnumerable<.
method GetValues(string) #
GetValues(string) #public IEnumerable<string> GetValues(string key)
Gets all values for a header key.
Parameters
key: The header key (case-insensitive).
Returns
All values for the key.
method Set(string, string) #
Set(string, string) #public void Set(string key, string value)
Sets a header, replacing any existing values.
Parameters
key: The header key.value: The header value.
method TryGetValue(string, out string) #
TryGetValue(string, out string) #public bool TryGetValue(string key, out string? value)
Tries to get a header value.
Parameters
key: The header key.value: The header value if found.
Returns
True if the header was found.
interface IEndpointDiscoveryProvider
public interface IEndpointDiscoveryProvider
Provides endpoint discovery functionality.
Members
| Member | Kind | Summary |
|---|---|---|
DiscoverEndpoints( | method | Discovers all endpoints in the application. |
method DiscoverEndpoints() #
DiscoverEndpoints() #IReadOnlyList<EndpointDescriptor> DiscoverEndpoints()
Discovers all endpoints in the application.
Returns
The discovered endpoints.
interface IEndpointDiscoveryService
public interface IEndpointDiscoveryService
Interface for discovering endpoints with YAML configuration support.
Members
| Member | Kind | Summary |
|---|---|---|
DiscoverEndpoints( | method | Discovers all endpoints, applying any YAML configuration overrides. |
method DiscoverEndpoints() #
DiscoverEndpoints() #IReadOnlyList<EndpointDescriptor> DiscoverEndpoints()
Discovers all endpoints, applying any YAML configuration overrides.
Returns
The discovered endpoints with overrides applied.
interface IEndpointOverrideMerger
public interface IEndpointOverrideMerger
Interface for merging endpoint overrides from YAML configuration.
Members
| Member | Kind | Summary |
|---|---|---|
Merge( | method | Merges YAML overrides with code-defined endpoints. |
method Merge(IReadOnlyList<EndpointDescriptor>, MicroserviceYamlConfig) #
Merge(IReadOnlyList<EndpointDescriptor>, MicroserviceYamlConfig) #IReadOnlyList<EndpointDescriptor> Merge(IReadOnlyList<EndpointDescriptor> codeEndpoints, MicroserviceYamlConfig? yamlConfig)
Merges YAML overrides with code-defined endpoints.
Parameters
codeEndpoints: The endpoints discovered from code.yamlConfig: The YAML configuration, if any.
Returns
The merged endpoints.
interface IEndpointRegistry
public interface IEndpointRegistry
Registry for looking up endpoint handlers by method and path.
Members
| Member | Kind | Summary |
|---|---|---|
GetAllEndpoints( | method | Gets all registered endpoints. |
TryMatch( | method | Tries to find a matching endpoint for the given method and path. |
method GetAllEndpoints() #
GetAllEndpoints() #IReadOnlyList<EndpointDescriptor> GetAllEndpoints()
Gets all registered endpoints.
Returns
All registered endpoint descriptors.
method TryMatch(string, string, out EndpointMatch) #
TryMatch(string, string, out EndpointMatch) #bool TryMatch(string method, string path, out EndpointMatch? match)
Tries to find a matching endpoint for the given method and path.
Parameters
method: The HTTP method.path: The request path.match: The matching endpoint information if found.
Returns
True if a matching endpoint was found.
interface IEndpointSchemaDefinitionProvider
public interface IEndpointSchemaDefinitionProvider
Optional provider for endpoint JSON schema definitions discovered at runtime.
Members
| Member | Kind | Summary |
|---|---|---|
DiscoverSchemaDefinitions( | method | Gets schema definitions keyed by schema identifier. |
method DiscoverSchemaDefinitions() #
DiscoverSchemaDefinitions() #IReadOnlyDictionary<string, SchemaDefinition> DiscoverSchemaDefinitions()
Gets schema definitions keyed by schema identifier.
interface IGeneratedEndpointProvider
public interface IGeneratedEndpointProvider
Interface implemented by the source-generated endpoint provider.
Members
| Member | Kind | Summary |
|---|---|---|
GetEndpoints( | method | Gets all discovered endpoint descriptors. |
GetHandlerTypes( | method | Gets all handler types for endpoint discovery. |
GetSchemaDefinitions( | method | Gets the schema definitions for OpenAPI and validation. |
RegisterHandlers( | method | Registers all endpoint handlers with the service collection. |
method GetEndpoints() #
GetEndpoints() #IReadOnlyList<EndpointDescriptor> GetEndpoints()
Gets all discovered endpoint descriptors.
method GetHandlerTypes() #
GetHandlerTypes() #IReadOnlyList<Type> GetHandlerTypes()
Gets all handler types for endpoint discovery.
method GetSchemaDefinitions() #
GetSchemaDefinitions() #IReadOnlyDictionary<string, SchemaDefinition> GetSchemaDefinitions()
Gets the schema definitions for OpenAPI and validation. Keys are schema IDs, values are JSON Schema definitions.
method RegisterHandlers(IServiceCollection) #
RegisterHandlers(IServiceCollection) #void RegisterHandlers(IServiceCollection services)
Registers all endpoint handlers with the service collection.
interface IHeaderCollection
public interface IHeaderCollection : IEnumerable<KeyValuePair<string, string>>
Abstraction for HTTP-style header collection.
Members
| Member | Kind | Summary |
|---|---|---|
this[string] | indexer | Gets a header value by key. |
ContainsKey( | method | Checks if a header exists. |
GetValues( | method | Gets all values for a header key. |
TryGetValue( | method | Tries to get a header value. |
indexer this[string] #
this[string] #string? this[string key] { get; }
Gets a header value by key.
Parameters
key: The header key (case-insensitive).
Returns
The header value, or null if not found.
method ContainsKey(string) #
ContainsKey(string) #bool ContainsKey(string key)
Checks if a header exists.
Parameters
key: The header key.
Returns
True if the header exists.
method GetValues(string) #
GetValues(string) #IEnumerable<string> GetValues(string key)
Gets all values for a header key.
Parameters
key: The header key (case-insensitive).
Returns
All values for the key.
method TryGetValue(string, out string) #
TryGetValue(string, out string) #bool TryGetValue(string key, out string? value)
Tries to get a header value.
Parameters
key: The header key.value: The header value if found.
Returns
True if the header was found.
interface IMicroserviceYamlLoader
public interface IMicroserviceYamlLoader
Interface for loading microservice YAML configuration.
Members
| Member | Kind | Summary |
|---|---|---|
Load( | method | Loads the microservice configuration from YAML. |
method Load() #
Load() #MicroserviceYamlConfig? Load()
Loads the microservice configuration from YAML.
Returns
The configuration, or null if no file is configured or file doesn’t exist.
interface IRawStellaEndpoint
public interface IRawStellaEndpoint : IStellaEndpoint
Interface for a raw Stella endpoint that handles requests with full context.
Members
| Member | Kind | Summary |
|---|---|---|
HandleAsync( | method | Handles the raw request with full context. |
method HandleAsync(RawRequestContext, CancellationToken) #
HandleAsync(RawRequestContext, CancellationToken) #Task<RawResponse> HandleAsync(RawRequestContext context, CancellationToken cancellationToken)
Handles the raw request with full context.
Parameters
context: The request context including headers, path parameters, and body stream.cancellationToken: Cancellation token.
Returns
The raw response including status code, headers, and body stream.
interface IRequestDispatcher
public interface IRequestDispatcher
Abstraction for dispatching Router request frames to handlers.
Members
| Member | Kind | Summary |
|---|---|---|
CanHandle( | method | Checks if this dispatcher can handle the given request. |
DispatchAsync( | method | Dispatches a REQUEST frame and returns a RESPONSE frame. |
method CanHandle(string, string) #
CanHandle(string, string) #bool CanHandle(string method, string path)
Checks if this dispatcher can handle the given request. Used by composite dispatchers to route to the appropriate handler.
Parameters
method: HTTP method.path: Request path (without query string).
Returns
True if this dispatcher can handle the request.
method DispatchAsync(RequestFrame, CancellationToken) #
DispatchAsync(RequestFrame, CancellationToken) #Task<ResponseFrame> DispatchAsync(RequestFrame request, CancellationToken cancellationToken)
Dispatches a REQUEST frame and returns a RESPONSE frame.
Parameters
request: The incoming REQUEST frame.cancellationToken: Cancellation token.
Returns
The RESPONSE frame.
interface IRouterConnectionManager
public interface IRouterConnectionManager
Manages connections to router gateways.
Members
| Member | Kind | Summary |
|---|---|---|
Connections | property | Gets the current connection states. |
InFlightRequestCount | property | Gets the number of requests currently being processed by this instance. |
BeginDrainAsync( | method | Begins graceful draining by reporting Draining to the router and emitting an immediate heartbeat so gateways stop sending new work. |
SendGoodbyeAsync( | method | Sends a best-effort Goodbye frame to request prompt deregistration. |
StartAsync( | method | Starts the connection manager. |
StopAsync( | method | Stops the connection manager. |
property Connections #
Connections #IReadOnlyList<ConnectionState> Connections { get; }
Gets the current connection states.
property InFlightRequestCount #
InFlightRequestCount #int InFlightRequestCount { get; }
Gets the number of requests currently being processed by this instance.
method BeginDrainAsync(CancellationToken) #
BeginDrainAsync(CancellationToken) #Task BeginDrainAsync(CancellationToken cancellationToken)
Begins graceful draining by reporting Draining to the router and emitting an immediate heartbeat so gateways stop sending new work.
Parameters
cancellationToken: Cancellation token.
method SendGoodbyeAsync(CancellationToken) #
SendGoodbyeAsync(CancellationToken) #Task SendGoodbyeAsync(CancellationToken cancellationToken)
Sends a best-effort Goodbye frame to request prompt deregistration. Calling this after the connection has already been torn down is a no-op.
Parameters
cancellationToken: Cancellation token.
method StartAsync(CancellationToken) #
StartAsync(CancellationToken) #Task StartAsync(CancellationToken cancellationToken)
Starts the connection manager.
Parameters
cancellationToken: Cancellation token.
method StopAsync(CancellationToken) #
StopAsync(CancellationToken) #Task StopAsync(CancellationToken cancellationToken)
Stops the connection manager.
Parameters
cancellationToken: Cancellation token.
interface IStellaEndpoint
public interface IStellaEndpoint
Marker interface for all Stella endpoints.
interface IStellaEndpoint<TRequest, TResponse>
public interface IStellaEndpoint<TRequest, TResponse> : IStellaEndpoint
Interface for a typed Stella endpoint with request and response.
Type parameters
TRequest: The request type.TResponse: The response type.
Members
| Member | Kind | Summary |
|---|---|---|
HandleAsync( | method | Handles the request. |
method HandleAsync(TRequest, CancellationToken) #
HandleAsync(TRequest, CancellationToken) #Task<TResponse> HandleAsync(TRequest request, CancellationToken cancellationToken)
Handles the request.
Parameters
request: The request.cancellationToken: Cancellation token.
Returns
The response.
interface IStellaEndpoint<TResponse>
public interface IStellaEndpoint<TResponse> : IStellaEndpoint
Interface for a typed Stella endpoint with response only (no request body).
Type parameters
TResponse: The response type.
Members
| Member | Kind | Summary |
|---|---|---|
HandleAsync( | method | Handles the request. |
method HandleAsync(CancellationToken) #
HandleAsync(CancellationToken) #Task<TResponse> HandleAsync(CancellationToken cancellationToken)
Handles the request.
Parameters
cancellationToken: Cancellation token.
Returns
The response.
class InflightRequestTracker
public sealed class InflightRequestTracker : IDisposable
Tracks in-flight requests and manages their cancellation tokens.
Members
| Member | Kind | Summary |
|---|---|---|
InflightRequestTracker( | constructor | Initializes a new instance of the InflightRequestTrackerclass. |
Count | property | Gets the count of in-flight requests. |
Cancel( | method | Cancels a specific request. |
CancelAll( | method | Cancels all in-flight requests. |
Complete( | method | Marks a request as completed and removes it from tracking. |
Dispose( | method | See IDisposable.. |
Track( | method | Starts tracking a request and returns a cancellation token for it. |
constructor InflightRequestTracker(ILogger<InflightRequestTracker>) #
InflightRequestTracker(ILogger<InflightRequestTracker>) #public InflightRequestTracker(ILogger<InflightRequestTracker> logger)
Initializes a new instance of the InflightRequestTrackerclass.
property Count #
Count #public int Count { get; }
Gets the count of in-flight requests.
method Cancel(Guid, string) #
Cancel(Guid, string) #public bool Cancel(Guid correlationId, string? reason)
Cancels a specific request.
Parameters
correlationId: The correlation ID of the request to cancel.reason: The reason for cancellation.
Returns
True if the request was found and cancelled; otherwise false.
method CancelAll(string) #
CancelAll(string) #public void CancelAll(string reason)
Cancels all in-flight requests.
Parameters
reason: The reason for cancellation.
method Complete(Guid) #
Complete(Guid) #public void Complete(Guid correlationId)
Marks a request as completed and removes it from tracking.
Parameters
correlationId: The correlation ID of the completed request.
method Dispose() #
Dispose() #public void Dispose()
See IDisposable..
method Track(Guid) #
Track(Guid) #public CancellationToken Track(Guid correlationId)
Starts tracking a request and returns a cancellation token for it.
Parameters
correlationId: The correlation ID of the request.
Returns
A cancellation token that will be triggered if the request is cancelled.
class MicroserviceHostedService
public sealed class MicroserviceHostedService : IHostedService, IDisposable
Hosted service that manages the microservice lifecycle.
Members
| Member | Kind | Summary |
|---|---|---|
MicroserviceHostedService( | constructor | Initializes a new instance of the MicroserviceHostedServiceclass. |
Dispose( | method | See IDisposable.. |
StartAsync( | method | See IHosted. |
StopAsync( | method | See IHosted. |
constructor MicroserviceHostedService(IRouterConnectionManager, IHostApplicationLifetime, ILogger<MicroserviceHostedService>, IOptions<StellaMicroserviceOptions>, SchemaProviderDiscoveryDiagnostics) #
MicroserviceHostedService(IRouterConnectionManager, IHostApplicationLifetime, ILogger<MicroserviceHostedService>, IOptions<StellaMicroserviceOptions>, SchemaProviderDiscoveryDiagnostics) #public MicroserviceHostedService(IRouterConnectionManager connectionManager, IHostApplicationLifetime applicationLifetime, ILogger<MicroserviceHostedService> logger, IOptions<StellaMicroserviceOptions> options, SchemaProviderDiscoveryDiagnostics? schemaDiagnostics = null)
Initializes a new instance of the MicroserviceHostedServiceclass.
method Dispose() #
Dispose() #public void Dispose()
See IDisposable..
method StartAsync(CancellationToken) #
StartAsync(CancellationToken) #public Task StartAsync(CancellationToken cancellationToken)
See IHosted.
method StopAsync(CancellationToken) #
StopAsync(CancellationToken) #public Task StopAsync(CancellationToken cancellationToken)
See IHosted.
class MicroserviceServiceCollectionExtensions
public static class MicroserviceServiceCollectionExtensions
Extension methods for registering Stella microservice services.
Members
| Member | Kind | Summary |
|---|---|---|
AddStellaEndpoint< | extension method | Registers an endpoint handler type for dependency injection. |
AddStellaMicroservice( | extension method | Adds Stella microservice services to the service collection. |
AddStellaMicroservice< | extension method | Adds Stella microservice services with a custom endpoint discovery provider. |
AddStellaSchemaProvider< | extension method | Registers a generated schema provider for schema validation. |
extension method AddStellaEndpoint<THandler>(IServiceCollection) #
AddStellaEndpoint<THandler>(IServiceCollection) #public static IServiceCollection AddStellaEndpoint<THandler>(this IServiceCollection services) where THandler : class, IStellaEndpoint
Registers an endpoint handler type for dependency injection.
Type parameters
THandler: The endpoint handler type.
Parameters
services: The service collection.
Returns
The service collection for chaining.
extension method AddStellaMicroservice(IServiceCollection, Action<StellaMicroserviceOptions>) #
AddStellaMicroservice(IServiceCollection, Action<StellaMicroserviceOptions>) #public static IServiceCollection AddStellaMicroservice(this IServiceCollection services, Action<StellaMicroserviceOptions> configure)
Adds Stella microservice services to the service collection.
Parameters
services: The service collection.configure: Action to configure the microservice options.
Returns
The service collection for chaining.
extension method AddStellaMicroservice<TDiscovery>(IServiceCollection, Action<StellaMicroserviceOptions>) #
AddStellaMicroservice<TDiscovery>(IServiceCollection, Action<StellaMicroserviceOptions>) #public static IServiceCollection AddStellaMicroservice<TDiscovery>(this IServiceCollection services, Action<StellaMicroserviceOptions> configure) where TDiscovery : class, IEndpointDiscoveryProvider
Adds Stella microservice services with a custom endpoint discovery provider.
Type parameters
TDiscovery: The endpoint discovery provider type.
Parameters
services: The service collection.configure: Action to configure the microservice options.
Returns
The service collection for chaining.
extension method AddStellaSchemaProvider<TProvider>(IServiceCollection) #
AddStellaSchemaProvider<TProvider>(IServiceCollection) #public static IServiceCollection AddStellaSchemaProvider<TProvider>(this IServiceCollection services) where TProvider : class, IGeneratedSchemaProvider
Registers a generated schema provider for schema validation.
Type parameters
TProvider: The generated schema provider type.
Parameters
services: The service collection.
Returns
The service collection for chaining.
class MicroserviceYamlConfig
public sealed class MicroserviceYamlConfig
Root configuration for microservice endpoint overrides loaded from YAML.
Members
| Member | Kind | Summary |
|---|---|---|
MicroserviceYamlConfig( | constructor | Creates an instance of Microservice. |
Endpoints | property | Gets or sets the endpoint override configurations. |
constructor MicroserviceYamlConfig() #
MicroserviceYamlConfig() #public MicroserviceYamlConfig()
Creates an instance of Microservice.
property Endpoints #
Endpoints #public List<EndpointOverrideConfig> Endpoints { get; set; }
Gets or sets the endpoint override configurations.
class MicroserviceYamlLoader
public sealed class MicroserviceYamlLoader : IMicroserviceYamlLoader
Loads microservice configuration from a YAML file.
Members
| Member | Kind | Summary |
|---|---|---|
MicroserviceYamlLoader( | constructor | Initializes a new instance of the MicroserviceYamlLoaderclass. |
Load( | method | Loads the microservice configuration from YAML. |
constructor MicroserviceYamlLoader(StellaMicroserviceOptions, ILogger<MicroserviceYamlLoader>) #
MicroserviceYamlLoader(StellaMicroserviceOptions, ILogger<MicroserviceYamlLoader>) #public MicroserviceYamlLoader(StellaMicroserviceOptions options, ILogger<MicroserviceYamlLoader> logger)
Initializes a new instance of the MicroserviceYamlLoaderclass.
method Load() #
Load() #public MicroserviceYamlConfig? Load()
Loads the microservice configuration from YAML.
Returns
The configuration, or null if no file is configured or file doesn’t exist.
class RawRequestContext
public sealed class RawRequestContext
Context for a raw request.
Members
| Member | Kind | Summary |
|---|---|---|
RawRequestContext( | constructor | Creates an instance of RawRequestContext. |
Body | property | Gets the request body stream. |
CancellationToken | property | Gets the cancellation token. |
CorrelationId | property | Gets the correlation ID for request tracking. |
Headers | property | Gets the request headers. |
Method | property | Gets the HTTP method. |
Path | property | Gets the request path. |
PathParameters | property | Gets the path parameters extracted from route templates. |
QueryParameters | property | Gets the query parameters extracted from the request path. |
constructor RawRequestContext() #
RawRequestContext() #public RawRequestContext()
Creates an instance of RawRequestContext.
property Body #
Body #public Stream Body { get; init; }
Gets the request body stream.
property CancellationToken #
CancellationToken #public CancellationToken CancellationToken { get; init; }
Gets the cancellation token.
property CorrelationId #
CorrelationId #public string? CorrelationId { get; init; }
Gets the correlation ID for request tracking.
property Headers #
Headers #public IHeaderCollection Headers { get; init; }
Gets the request headers.
property Method #
Method #public string Method { get; init; }
Gets the HTTP method.
property Path #
Path #public string Path { get; init; }
Gets the request path.
property PathParameters #
PathParameters #public IReadOnlyDictionary<string, string> PathParameters { get; init; }
Gets the path parameters extracted from route templates.
property QueryParameters #
QueryParameters #public IReadOnlyDictionary<string, string> QueryParameters { get; init; }
Gets the query parameters extracted from the request path.
class RawResponse
public sealed class RawResponse
Represents a raw response from an endpoint.
Members
| Member | Kind | Summary |
|---|---|---|
RawResponse( | constructor | Creates an instance of RawResponse. |
Body | property | Gets or sets the response body stream. |
Headers | property | Gets or sets the response headers. |
StatusCode | property | Gets or sets the HTTP status code. |
BadRequest( | method | Creates a 400 Bad Request response. |
Error( | method | Creates an error response with a message body. |
InternalError( | method | Creates a 500 Internal Server Error response. |
NoContent( | method | Creates a 204 No Content response. |
NotFound( | method | Creates a 404 Not Found response. |
Ok( | method | Creates a 200 OK response with a body. |
Ok( | method | Creates a 200 OK response with a byte array body. |
Ok( | method | Creates a 200 OK response with a string body. |
constructor RawResponse() #
RawResponse() #public RawResponse()
Creates an instance of RawResponse.
property Body #
Body #public Stream Body { get; init; }
Gets or sets the response body stream.
property Headers #
Headers #public IHeaderCollection Headers { get; init; }
Gets or sets the response headers.
property StatusCode #
StatusCode #public int StatusCode { get; init; }
Gets or sets the HTTP status code.
method BadRequest(string) #
BadRequest(string) #public static RawResponse BadRequest(string? message = null)
Creates a 400 Bad Request response.
method Error(int, string) #
Error(int, string) #public static RawResponse Error(int statusCode, string message)
Creates an error response with a message body.
method InternalError(string) #
InternalError(string) #public static RawResponse InternalError(string? message = null)
Creates a 500 Internal Server Error response.
method NoContent() #
NoContent() #public static RawResponse NoContent()
Creates a 204 No Content response.
method NotFound(string) #
NotFound(string) #public static RawResponse NotFound(string? message = null)
Creates a 404 Not Found response.
method Ok(Stream) #
Ok(Stream) #public static RawResponse Ok(Stream body)
Creates a 200 OK response with a body.
method Ok(byte[]) #
Ok(byte[]) #public static RawResponse Ok(byte[] body)
Creates a 200 OK response with a byte array body.
method Ok(string) #
Ok(string) #public static RawResponse Ok(string body)
Creates a 200 OK response with a string body.
class ReflectionEndpointDiscoveryProvider
public sealed class ReflectionEndpointDiscoveryProvider : IEndpointDiscoveryProvider
Discovers endpoints using runtime reflection.
Members
| Member | Kind | Summary |
|---|---|---|
ReflectionEndpointDiscoveryProvider( | constructor | Initializes a new instance of the ReflectionEndpointDiscoveryProviderclass. |
DiscoverEndpoints( | method | Discovers all endpoints in the application. |
constructor ReflectionEndpointDiscoveryProvider(StellaMicroserviceOptions, IEnumerable<Assembly>, IServiceProviderIsService, ILogger) #
ReflectionEndpointDiscoveryProvider(StellaMicroserviceOptions, IEnumerable<Assembly>, IServiceProviderIsService, ILogger) #public ReflectionEndpointDiscoveryProvider(StellaMicroserviceOptions options, IEnumerable<Assembly>? assemblies = null, IServiceProviderIsService? serviceProviderIsService = null, ILogger? logger = null)
Initializes a new instance of the ReflectionEndpointDiscoveryProviderclass.
Parameters
options: The microservice options.assemblies: The assemblies to scan for endpoints.service: When set, an endpoint class that the service provider cannot resolve is skipped.Provider Is Service logger: Receives a warning for each assembly that cannot be scanned.
method DiscoverEndpoints() #
DiscoverEndpoints() #public IReadOnlyList<EndpointDescriptor> DiscoverEndpoints()
Discovers all endpoints in the application.
Returns
The discovered endpoints.
class RequestDispatcher
public sealed class RequestDispatcher : IRequestDispatcher
Dispatches incoming REQUEST frames to the appropriate endpoint handlers. This is the default dispatcher for [StellaEndpoint] attributed handlers.
Members
| Member | Kind | Summary |
|---|---|---|
RequestDispatcher( | constructor | Initializes a new instance of the RequestDispatcherclass. |
CanHandle( | method | Checks if this dispatcher can handle the given request. |
DispatchAsync( | method | Dispatches a REQUEST frame and returns a RESPONSE frame. |
constructor RequestDispatcher(IEndpointRegistry, IServiceProvider, ILogger<RequestDispatcher>, ISchemaRegistry, IRequestSchemaValidator, JsonSerializerOptions) #
RequestDispatcher(IEndpointRegistry, IServiceProvider, ILogger<RequestDispatcher>, ISchemaRegistry, IRequestSchemaValidator, JsonSerializerOptions) #public RequestDispatcher(IEndpointRegistry registry, IServiceProvider serviceProvider, ILogger<RequestDispatcher> logger, ISchemaRegistry? schemaRegistry = null, IRequestSchemaValidator? schemaValidator = null, JsonSerializerOptions? jsonOptions = null)
Initializes a new instance of the RequestDispatcherclass.
Parameters
registry: The endpoint registry.serviceProvider: The service provider for resolving handlers.logger: The logger.schemaRegistry: Optional schema registry for validation.schemaValidator: Optional schema validator.jsonOptions: Optional JSON serialization options.
method CanHandle(string, string) #
CanHandle(string, string) #public bool CanHandle(string method, string path)
Checks if this dispatcher can handle the given request. Used by composite dispatchers to route to the appropriate handler.
Parameters
method: HTTP method.path: Request path (without query string).
Returns
True if this dispatcher can handle the request.
method DispatchAsync(RequestFrame, CancellationToken) #
DispatchAsync(RequestFrame, CancellationToken) #public Task<ResponseFrame> DispatchAsync(RequestFrame request, CancellationToken cancellationToken)
Dispatches a REQUEST frame and returns a RESPONSE frame.
Parameters
request: The incoming REQUEST frame.cancellationToken: Cancellation token.
Returns
The RESPONSE frame.
class RouterConnectionManager
public sealed class RouterConnectionManager : IRouterConnectionManager, IDisposable
Manages connections to router gateways.
Members
| Member | Kind | Summary |
|---|---|---|
RouterConnectionManager( | constructor | Initializes a new instance of the RouterConnectionManagerclass. |
Connections | property | Gets the current connection states. |
CurrentStatus | property | Gets or sets the current health status reported by this instance. |
ErrorRate | property | Gets or sets the error rate (0.0 to 1.0). |
InFlightRequestCount | property | Gets or sets the count of in-flight requests. |
BeginDrainAsync( | method | Begins graceful draining by reporting Draining to the router and emitting an immediate heartbeat so gateways stop sending new work. |
Dispose( | method | See IDisposable.. |
SendGoodbyeAsync( | method | Sends a best-effort Goodbye frame to request prompt deregistration. |
StartAsync( | method | Starts the connection manager. |
StopAsync( | method | Stops the connection manager. |
constructor RouterConnectionManager(IOptions<StellaMicroserviceOptions>, IEndpointDiscoveryProvider, IRequestDispatcher, IMicroserviceTransport, ILogger<RouterConnectionManager>, IGeneratedEndpointProvider, IEndpointDiscoveryService) #
RouterConnectionManager(IOptions<StellaMicroserviceOptions>, IEndpointDiscoveryProvider, IRequestDispatcher, IMicroserviceTransport, ILogger<RouterConnectionManager>, IGeneratedEndpointProvider, IEndpointDiscoveryService) #public RouterConnectionManager(IOptions<StellaMicroserviceOptions> options, IEndpointDiscoveryProvider endpointDiscovery, IRequestDispatcher requestDispatcher, IMicroserviceTransport? microserviceTransport, ILogger<RouterConnectionManager> logger, IGeneratedEndpointProvider? generatedProvider = null, IEndpointDiscoveryService? endpointDiscoveryService = null)
Initializes a new instance of the RouterConnectionManagerclass.
Parameters
options: The microservice options.endpointDiscovery: The endpoint discovery provider.requestDispatcher: The request dispatcher.microservice: The transport to the gateways.Transport logger: The logger.generatedProvider: The source-generated endpoint provider, when present.endpoint: The endpoint discovery with theDiscovery Service StellaMicroserviceOptions.overrides applied, when registered (ConfigFilePath Addregisters it). The endpoints sent in HELLO come from it, so the gateway routes and authorizes by the same timeouts, streaming flags and required claims the service dispatches with; without it, the endpoints ofStella Microservice endpointDiscoveryare sent unchanged.
property Connections #
Connections #public IReadOnlyList<ConnectionState> Connections { get; }
Gets the current connection states.
property CurrentStatus #
CurrentStatus #public InstanceHealthStatus CurrentStatus { get; set; }
Gets or sets the current health status reported by this instance.
property ErrorRate #
ErrorRate #public double ErrorRate { get; set; }
Gets or sets the error rate (0.0 to 1.0).
property InFlightRequestCount #
InFlightRequestCount #public int InFlightRequestCount { get; set; }
Gets or sets the count of in-flight requests.
method BeginDrainAsync(CancellationToken) #
BeginDrainAsync(CancellationToken) #public Task BeginDrainAsync(CancellationToken cancellationToken)
Begins graceful draining by reporting Draining to the router and emitting an immediate heartbeat so gateways stop sending new work.
Parameters
cancellationToken: Cancellation token.
method Dispose() #
Dispose() #public void Dispose()
See IDisposable..
method SendGoodbyeAsync(CancellationToken) #
SendGoodbyeAsync(CancellationToken) #public Task SendGoodbyeAsync(CancellationToken cancellationToken)
Sends a best-effort Goodbye frame to request prompt deregistration. Calling this after the connection has already been torn down is a no-op.
Parameters
cancellationToken: Cancellation token.
method StartAsync(CancellationToken) #
StartAsync(CancellationToken) #public Task StartAsync(CancellationToken cancellationToken)
Starts the connection manager.
Parameters
cancellationToken: Cancellation token.
method StopAsync(CancellationToken) #
StopAsync(CancellationToken) #public Task StopAsync(CancellationToken cancellationToken)
Stops the connection manager.
Parameters
cancellationToken: Cancellation token.
class RouterEndpointConfig
public sealed class RouterEndpointConfig
Configuration for a router endpoint.
Members
| Member | Kind | Summary |
|---|---|---|
RouterEndpointConfig( | constructor | Creates an instance of RouterEndpointConfig. |
Host | property | Gets or sets the router host. |
Port | property | Gets or sets the router port. |
TransportType | property | Gets or sets the transport type to use. |
constructor RouterEndpointConfig() #
RouterEndpointConfig() #public RouterEndpointConfig()
Creates an instance of RouterEndpointConfig.
property Host #
Host #public required string Host { get; set; }
Gets or sets the router host.
property Port #
Port #public required int Port { get; set; }
Gets or sets the router port.
property TransportType #
TransportType #public TransportType TransportType { get; set; }
Gets or sets the transport type to use.
class SchemaProviderDiscoveryDiagnostics
public sealed class SchemaProviderDiscoveryDiagnostics
Captures schema provider discovery issues for startup diagnostics.
Members
| Member | Kind | Summary |
|---|---|---|
SchemaProviderDiscoveryDiagnostics( | constructor | Initializes a new instance of the SchemaProviderDiscoveryDiagnosticsclass. |
Issues | property | Gets the discovery issues. |
constructor SchemaProviderDiscoveryDiagnostics(IReadOnlyList<SchemaProviderDiscoveryIssue>) #
SchemaProviderDiscoveryDiagnostics(IReadOnlyList<SchemaProviderDiscoveryIssue>) #public SchemaProviderDiscoveryDiagnostics(IReadOnlyList<SchemaProviderDiscoveryIssue> issues)
Initializes a new instance of the SchemaProviderDiscoveryDiagnosticsclass.
Parameters
issues: The discovery issues.
property Issues #
Issues #public IReadOnlyList<SchemaProviderDiscoveryIssue> Issues { get; }
Gets the discovery issues.
record SchemaProviderDiscoveryIssue
public sealed record SchemaProviderDiscoveryIssue
Represents a schema provider discovery issue.
Parameters
AssemblyName: The assembly whose schema provider could not be read.Message: What went wrong.
Members
| Member | Kind | Summary |
|---|---|---|
SchemaProviderDiscoveryIssue( | constructor | Represents a schema provider discovery issue. |
AssemblyName | property | The assembly whose schema provider could not be read. |
Message | property | What went wrong. |
constructor SchemaProviderDiscoveryIssue(string, string) #
SchemaProviderDiscoveryIssue(string, string) #public SchemaProviderDiscoveryIssue(string AssemblyName, string Message)
Represents a schema provider discovery issue.
Parameters
AssemblyName: The assembly whose schema provider could not be read.Message: What went wrong.
property AssemblyName #
AssemblyName #public string AssemblyName { get; init; }
The assembly whose schema provider could not be read.
property Message #
Message #public string Message { get; init; }
What went wrong.
class StellaEndpointAttribute
public sealed class StellaEndpointAttribute : Attribute
Marks a class as a Stella endpoint handler.
Applies to: Class. Allow multiple: no. Inherited: no.
Members
| Member | Kind | Summary |
|---|---|---|
StellaEndpointAttribute( | constructor | Initializes a new instance of the StellaEndpointAttributeclass. |
Method | property | Gets the HTTP method for this endpoint. |
Path | property | Gets the path for this endpoint. |
RequiredClaims | property | Gets or sets the required claim types for this endpoint. |
SupportsStreaming | property | Gets or sets whether this endpoint supports streaming. |
TimeoutSeconds | property | Gets or sets the default timeout in seconds. |
constructor StellaEndpointAttribute(string, string) #
StellaEndpointAttribute(string, string) #public StellaEndpointAttribute(string method, string path)
Initializes a new instance of the StellaEndpointAttributeclass.
Parameters
method: The HTTP method.path: The endpoint path.
property Method #
Method #public string Method { get; }
Gets the HTTP method for this endpoint.
property Path #
Path #public string Path { get; }
Gets the path for this endpoint.
property RequiredClaims #
RequiredClaims #public string[] RequiredClaims { get; set; }
Gets or sets the required claim types for this endpoint.
property SupportsStreaming #
SupportsStreaming #public bool SupportsStreaming { get; set; }
Gets or sets whether this endpoint supports streaming. Default: false.
property TimeoutSeconds #
TimeoutSeconds #public int TimeoutSeconds { get; set; }
Gets or sets the default timeout in seconds. Default: 30 seconds.
class StellaMicroserviceOptions
public sealed class StellaMicroserviceOptions
Options for configuring a Stella microservice.
Members
| Member | Kind | Summary |
|---|---|---|
StellaMicroserviceOptions( | constructor | Creates an instance of Stella. |
ConfigFilePath | property | Gets or sets the optional path to a YAML config file for endpoint overrides. |
ContactInfo | property | Gets or sets the contact information for OpenAPI documentation. |
DrainDeadline | property | Gets or sets how long shutdown waits for in-flight requests to finish after the instance starts reporting Draining. |
DrainPollInterval | property | Gets or sets how often shutdown polls the in-flight request count during the drain deadline. |
HeartbeatInterval | property | Gets or sets the heartbeat interval. |
InstanceId | property | Gets or sets the unique instance identifier. |
ReconnectBackoffInitial | property | Gets or sets the initial reconnect delay. |
ReconnectBackoffMax | property | Gets or sets the maximum reconnect backoff. |
Region | property | Gets or sets the region where this instance is deployed. |
Routers | property | Gets the router endpoints to connect to. |
ServiceDescription | property | Gets or sets the service description for OpenAPI documentation. |
ServiceName | property | Gets or sets the service name. |
Version | property | Gets or sets the semantic version. |
Weight | property | Gets or sets the routing weight this instance advertises in HELLO. |
Validate( | method | Validates the options and throws if invalid. |
constructor StellaMicroserviceOptions() #
StellaMicroserviceOptions() #public StellaMicroserviceOptions()
Creates an instance of Stella.
property ConfigFilePath #
ConfigFilePath #public string? ConfigFilePath { get; set; }
Gets or sets the optional path to a YAML config file for endpoint overrides.
property ContactInfo #
ContactInfo #public string? ContactInfo { get; set; }
Gets or sets the contact information for OpenAPI documentation.
property DrainDeadline #
DrainDeadline #public TimeSpan DrainDeadline { get; set; }
Gets or sets how long shutdown waits for in-flight requests to finish after the instance starts reporting Draining. Default: 25 seconds.
property DrainPollInterval #
DrainPollInterval #public TimeSpan DrainPollInterval { get; set; }
Gets or sets how often shutdown polls the in-flight request count during the drain deadline. Default: 100 milliseconds.
property HeartbeatInterval #
HeartbeatInterval #public TimeSpan HeartbeatInterval { get; set; }
Gets or sets the heartbeat interval. Default: 10 seconds, below the router gateway host’s default degraded threshold (20 seconds in effect) and a third of its default stale threshold (30 seconds), so a service with the defaults is never reported degraded or stale between heartbeats. A longer interval needs the gateway’s Gateway:Health thresholds raised to match; the service logs a warning at start-up when the interval is longer than that stale threshold.
property InstanceId #
InstanceId #public string InstanceId { get; set; }
Gets or sets the unique instance identifier. Auto-generated if not provided.
property ReconnectBackoffInitial #
ReconnectBackoffInitial #public TimeSpan ReconnectBackoffInitial { get; set; }
Gets or sets the initial reconnect delay. Default: 1 second.
property ReconnectBackoffMax #
ReconnectBackoffMax #public TimeSpan ReconnectBackoffMax { get; set; }
Gets or sets the maximum reconnect backoff. Default: 1 minute.
property Region #
Region #public required string Region { get; set; }
Gets or sets the region where this instance is deployed.
property Routers #
Routers #public List<RouterEndpointConfig> Routers { get; set; }
Gets the router endpoints to connect to. At least one router endpoint is required.
property ServiceDescription #
ServiceDescription #public string? ServiceDescription { get; set; }
Gets or sets the service description for OpenAPI documentation.
property ServiceName #
ServiceName #public required string ServiceName { get; set; }
Gets or sets the service name.
property Version #
Version #public required string Version { get; set; }
Gets or sets the semantic version. Must be valid semver (e.g., “1.0.0”, “2.1.0-beta.1”).
property Weight #
Weight #public int Weight { get; set; }
Gets or sets the routing weight this instance advertises in HELLO.
method Validate() #
Validate() #public void Validate()
Validates the options and throws if invalid.
class TypedEndpointAdapter
public static class TypedEndpointAdapter
Adapts typed endpoint handlers to the raw endpoint interface.
Members
| Member | Kind | Summary |
|---|---|---|
Adapt( | method | Creates a raw handler function from a raw endpoint. |
Adapt< | method | Creates a raw handler function from a typed endpoint with request and response. |
Adapt< | method | Creates a raw handler function from a typed endpoint with response only. |
method Adapt(IRawStellaEndpoint) #
Adapt(IRawStellaEndpoint) #public static Func<RawRequestContext, CancellationToken, Task<RawResponse>> Adapt(IRawStellaEndpoint handler)
Creates a raw handler function from a raw endpoint.
Parameters
handler: The raw handler.
Returns
A raw handler function.
method Adapt<TRequest, TResponse>(IStellaEndpoint<TRequest, TResponse>, JsonSerializerOptions) #
Adapt<TRequest, TResponse>(IStellaEndpoint<TRequest, TResponse>, JsonSerializerOptions) #public static Func<RawRequestContext, CancellationToken, Task<RawResponse>> Adapt<TRequest, TResponse>(IStellaEndpoint<TRequest, TResponse> handler, JsonSerializerOptions? jsonOptions = null)
Creates a raw handler function from a typed endpoint with request and response.
Type parameters
TRequest: The request type.TResponse: The response type.
Parameters
handler: The typed handler.jsonOptions: Optional JSON serialization options.
Returns
A raw handler function.
method Adapt<TResponse>(IStellaEndpoint<TResponse>, JsonSerializerOptions) #
Adapt<TResponse>(IStellaEndpoint<TResponse>, JsonSerializerOptions) #public static Func<RawRequestContext, CancellationToken, Task<RawResponse>> Adapt<TResponse>(IStellaEndpoint<TResponse> handler, JsonSerializerOptions? jsonOptions = null)
Creates a raw handler function from a typed endpoint with response only.
Type parameters
TResponse: The response type.
Parameters
handler: The typed handler.jsonOptions: Optional JSON serialization options.
Returns
A raw handler function.
class ValidateSchemaAttribute
public sealed class ValidateSchemaAttribute : Attribute
Enables JSON Schema validation for this endpoint. Schemas are generated from TRequest/TResponse types at compile time.
Applies to: Class. Allow multiple: no. Inherited: no.
Remarks
When applied to an endpoint class that implements IStellaEndpoint<, the source generator will generate a JSON Schema from the request type and validate all incoming requests against it. Invalid requests receive a 422 Unprocessable Entity response with detailed errors.
Response validation is opt-in via ValidateSchemaAttribute.. This is useful for catching bugs in handlers but adds overhead.
Example
// Basic usage - validates request only
[StellaEndpoint("POST", "/invoices")]
[ValidateSchema]
public sealed class CreateInvoiceEndpoint : IStellaEndpoint<CreateInvoiceRequest, CreateInvoiceResponse>
// With response validation
[StellaEndpoint("GET", "/invoices/{id}")]
[ValidateSchema(ValidateResponse = true)]
public sealed class GetInvoiceEndpoint : IStellaEndpoint<GetInvoiceRequest, GetInvoiceResponse>
Members
| Member | Kind | Summary |
|---|---|---|
ValidateSchemaAttribute( | constructor | Creates an instance of Validate. |
Deprecated | property | Gets or sets whether this endpoint is deprecated. |
Description | property | Gets or sets the OpenAPI operation description. |
Summary | property | Gets or sets the OpenAPI operation summary. |
Tags | property | Gets or sets the OpenAPI tags for this endpoint. |
ValidateRequest | property | Gets or sets whether to validate request bodies. |
ValidateResponse | property | Gets or sets whether to validate response bodies. |
constructor ValidateSchemaAttribute() #
ValidateSchemaAttribute() #public ValidateSchemaAttribute()
Creates an instance of Validate.
property Deprecated #
Deprecated #public bool Deprecated { get; set; }
Gets or sets whether this endpoint is deprecated. Deprecated endpoints are marked as such in OpenAPI documentation.
property Description #
Description #public string? Description { get; set; }
Gets or sets the OpenAPI operation description. A longer description of the endpoint’s behavior.
property Summary #
Summary #public string? Summary { get; set; }
Gets or sets the OpenAPI operation summary. A brief description of what the endpoint does.
property Tags #
Tags #public string[]? Tags { get; set; }
Gets or sets the OpenAPI tags for this endpoint. Tags are used to group endpoints in documentation.
property ValidateRequest #
ValidateRequest #public bool ValidateRequest { get; set; }
Gets or sets whether to validate request bodies. Default is true.
property ValidateResponse #
ValidateResponse #public bool ValidateResponse { get; set; }
Gets or sets whether to validate response bodies. Default is false. Enable for debugging or strict contract enforcement: a typed response that fails the schema generated from TResponse is logged and answered with a generic 500.
namespace StellaOps.Microservice.Endpoints
| Type | Kind | Description |
|---|---|---|
EndpointSchemaInfo | record | Information about an endpoint’s schema availability. |
SchemaDetailEndpoint | class | Endpoint that returns a specific schema as application/schema+json. |
SchemaIndexEndpoint | class | Endpoint that returns an index of all available schemas. |
SchemaIndexResponse | record | Response model for the schema index endpoint. |
record EndpointSchemaInfo
public sealed record EndpointSchemaInfo
Information about an endpoint’s schema availability.
Members
| Member | Kind | Summary |
|---|---|---|
EndpointSchemaInfo( | constructor | Creates an instance of EndpointSchemaInfo. |
HasRequestSchema | property | Whether a request schema is available. |
HasResponseSchema | property | Whether a response schema is available. |
Method | property | The HTTP method. |
Path | property | The endpoint path. |
RequestSchemaUrl | property | Link to fetch the request schema. |
ResponseSchemaUrl | property | Link to fetch the response schema. |
constructor EndpointSchemaInfo() #
EndpointSchemaInfo() #public EndpointSchemaInfo()
Creates an instance of EndpointSchemaInfo.
property HasRequestSchema #
HasRequestSchema #public bool HasRequestSchema { get; init; }
Whether a request schema is available.
property HasResponseSchema #
HasResponseSchema #public bool HasResponseSchema { get; init; }
Whether a response schema is available.
property Method #
Method #public required string Method { get; init; }
The HTTP method.
property Path #
Path #public required string Path { get; init; }
The endpoint path.
property RequestSchemaUrl #
RequestSchemaUrl #public string? RequestSchemaUrl { get; init; }
Link to fetch the request schema.
property ResponseSchemaUrl #
ResponseSchemaUrl #public string? ResponseSchemaUrl { get; init; }
Link to fetch the response schema.
class SchemaDetailEndpoint
public sealed class SchemaDetailEndpoint : IRawStellaEndpoint
Endpoint that returns a specific schema as application/schema+json. Supports ETag and If-None-Match for caching.
Members
| Member | Kind | Summary |
|---|---|---|
SchemaDetailEndpoint( | constructor | Initializes a new instance of the SchemaDetailEndpointclass. |
HandleAsync( | method | Handles the raw request with full context. |
constructor SchemaDetailEndpoint(ISchemaRegistry) #
SchemaDetailEndpoint(ISchemaRegistry) #public SchemaDetailEndpoint(ISchemaRegistry schemaRegistry)
Initializes a new instance of the SchemaDetailEndpointclass.
Parameters
schemaRegistry: The schema registry.
method HandleAsync(RawRequestContext, CancellationToken) #
HandleAsync(RawRequestContext, CancellationToken) #public Task<RawResponse> HandleAsync(RawRequestContext context, CancellationToken cancellationToken)
Handles the raw request with full context.
Parameters
context: The request context including headers, path parameters, and body stream.cancellationToken: Cancellation token.
Returns
The raw response including status code, headers, and body stream.
class SchemaIndexEndpoint
public sealed class SchemaIndexEndpoint : IStellaEndpoint<SchemaIndexResponse>
Endpoint that returns an index of all available schemas.
Members
| Member | Kind | Summary |
|---|---|---|
SchemaIndexEndpoint( | constructor | Initializes a new instance of the SchemaIndexEndpointclass. |
HandleAsync( | method | Handles the request. |
constructor SchemaIndexEndpoint(ISchemaRegistry) #
SchemaIndexEndpoint(ISchemaRegistry) #public SchemaIndexEndpoint(ISchemaRegistry schemaRegistry)
Initializes a new instance of the SchemaIndexEndpointclass.
Parameters
schemaRegistry: The schema registry.
method HandleAsync(CancellationToken) #
HandleAsync(CancellationToken) #public Task<SchemaIndexResponse> HandleAsync(CancellationToken cancellationToken)
Handles the request.
Parameters
cancellationToken: Cancellation token.
Returns
The response.
record SchemaIndexResponse
public sealed record SchemaIndexResponse
Response model for the schema index endpoint.
Members
| Member | Kind | Summary |
|---|---|---|
SchemaIndexResponse( | constructor | Creates an instance of SchemaIndexResponse. |
Endpoints | property | List of endpoints with schema information. |
constructor SchemaIndexResponse() #
SchemaIndexResponse() #public SchemaIndexResponse()
Creates an instance of SchemaIndexResponse.
property Endpoints #
Endpoints #public required IReadOnlyList<EndpointSchemaInfo> Endpoints { get; init; }
List of endpoints with schema information.
namespace StellaOps.Microservice.Streaming
| Type | Kind | Description |
|---|---|---|
StreamChunk | record | Represents a chunk of streaming data. |
StreamingRequestBodyStream | class | A read-only stream that reads from a channel of data chunks. |
StreamingResponseBodyStream | class | A write-only stream that writes chunks to a channel. |
record StreamChunk
public sealed record StreamChunk
Represents a chunk of streaming data.
Members
| Member | Kind | Summary |
|---|---|---|
StreamChunk( | constructor | Creates an instance of StreamChunk. |
Data | property | Gets the chunk data. |
EndOfStream | property | Gets a value indicating whether this is the final chunk. |
SequenceNumber | property | Gets the sequence number. |
constructor StreamChunk() #
StreamChunk() #public StreamChunk()
Creates an instance of StreamChunk.
property Data #
Data #public byte[] Data { get; init; }
Gets the chunk data.
property EndOfStream #
EndOfStream #public bool EndOfStream { get; init; }
Gets a value indicating whether this is the final chunk.
property SequenceNumber #
SequenceNumber #public int SequenceNumber { get; init; }
Gets the sequence number.
class StreamingRequestBodyStream
public sealed class StreamingRequestBodyStream : Stream
A read-only stream that reads from a channel of data chunks. Used to expose streaming request body to handlers.
Members
| Member | Kind | Summary |
|---|---|---|
StreamingRequestBodyStream( | constructor | Initializes a new instance of the StreamingRequestBodyStreamclass. |
CanRead | property | See Stream.CanRead. |
CanSeek | property | See Stream.CanSeek. |
CanWrite | property | See Stream.CanWrite. |
Length | property | See Stream.Length. |
Position | property | See Stream.Position. |
Flush( | method | See Stream.Flush(). |
Read( | method | See Stream.. |
ReadAsync( | method | See Stream.. |
ReadAsync( | method | See Stream.. |
Seek( | method | See Stream.. |
SetLength( | method | See Stream.. |
Write( | method | See Stream.. |
constructor StreamingRequestBodyStream(ChannelReader<StreamChunk>, CancellationToken) #
StreamingRequestBodyStream(ChannelReader<StreamChunk>, CancellationToken) #public StreamingRequestBodyStream(ChannelReader<StreamChunk> reader, CancellationToken cancellationToken)
Initializes a new instance of the StreamingRequestBodyStreamclass.
Parameters
reader: The channel reader for incoming chunks.cancellationToken: Cancellation token.
property CanRead #
CanRead #public override bool CanRead { get; }
See Stream.CanRead.
property CanSeek #
CanSeek #public override bool CanSeek { get; }
See Stream.CanSeek.
property CanWrite #
CanWrite #public override bool CanWrite { get; }
See Stream.CanWrite.
property Length #
Length #public override long Length { get; }
See Stream.Length.
property Position #
Position #public override long Position { get; set; }
See Stream.Position.
method Flush() #
Flush() #public override void Flush()
See Stream.Flush().
method Read(byte[], int, int) #
Read(byte[], int, int) #public override int Read(byte[] buffer, int offset, int count)
See Stream..
method ReadAsync(Memory<byte>, CancellationToken) #
ReadAsync(Memory<byte>, CancellationToken) #public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default)
See Stream..
method ReadAsync(byte[], int, int, CancellationToken) #
ReadAsync(byte[], int, int, CancellationToken) #public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
See Stream..
method Seek(long, SeekOrigin) #
Seek(long, SeekOrigin) #public override long Seek(long offset, SeekOrigin origin)
See Stream..
method SetLength(long) #
SetLength(long) #public override void SetLength(long value)
See Stream..
method Write(byte[], int, int) #
Write(byte[], int, int) #public override void Write(byte[] buffer, int offset, int count)
See Stream..
class StreamingResponseBodyStream
public sealed class StreamingResponseBodyStream : Stream
A write-only stream that writes chunks to a channel. Used to enable streaming response body from handlers.
Members
| Member | Kind | Summary |
|---|---|---|
StreamingResponseBodyStream( | constructor | Initializes a new instance of the StreamingResponseBodyStreamclass. |
CanRead | property | See Stream.CanRead. |
CanSeek | property | See Stream.CanSeek. |
CanWrite | property | See Stream.CanWrite. |
Length | property | See Stream.Length. |
Position | property | See Stream.Position. |
CompleteAsync( | method | Completes the stream by flushing remaining data and sending end-of-stream signal. |
DisposeAsync( | method | See Stream.. |
Flush( | method | See Stream.Flush(). |
FlushAsync( | method | See Stream.. |
Read( | method | See Stream.. |
Seek( | method | See Stream.. |
SetLength( | method | See Stream.. |
Write( | method | See Stream.. |
WriteAsync( | method | See Stream.. |
WriteAsync( | method | See Stream.. |
constructor StreamingResponseBodyStream(ChannelWriter<StreamChunk>, int, CancellationToken) #
StreamingResponseBodyStream(ChannelWriter<StreamChunk>, int, CancellationToken) #public StreamingResponseBodyStream(ChannelWriter<StreamChunk> writer, int chunkSize, CancellationToken cancellationToken)
Initializes a new instance of the StreamingResponseBodyStreamclass.
Parameters
writer: The channel writer for outgoing chunks.chunkSize: The chunk size for buffered writes.cancellationToken: Cancellation token.
property CanRead #
CanRead #public override bool CanRead { get; }
See Stream.CanRead.
property CanSeek #
CanSeek #public override bool CanSeek { get; }
See Stream.CanSeek.
property CanWrite #
CanWrite #public override bool CanWrite { get; }
See Stream.CanWrite.
property Length #
Length #public override long Length { get; }
See Stream.Length.
property Position #
Position #public override long Position { get; set; }
See Stream.Position.
method CompleteAsync(CancellationToken) #
CompleteAsync(CancellationToken) #public Task CompleteAsync(CancellationToken cancellationToken = default)
Completes the stream by flushing remaining data and sending end-of-stream signal.
method DisposeAsync() #
DisposeAsync() #public override ValueTask DisposeAsync()
See Stream..
method Flush() #
Flush() #public override void Flush()
See Stream.Flush().
method FlushAsync(CancellationToken) #
FlushAsync(CancellationToken) #public override Task FlushAsync(CancellationToken cancellationToken)
See Stream..
method Read(byte[], int, int) #
Read(byte[], int, int) #public override int Read(byte[] buffer, int offset, int count)
See Stream..
method Seek(long, SeekOrigin) #
Seek(long, SeekOrigin) #public override long Seek(long offset, SeekOrigin origin)
See Stream..
method SetLength(long) #
SetLength(long) #public override void SetLength(long value)
See Stream..
method Write(byte[], int, int) #
Write(byte[], int, int) #public override void Write(byte[] buffer, int offset, int count)
See Stream..
method WriteAsync(ReadOnlyMemory<byte>, CancellationToken) #
WriteAsync(ReadOnlyMemory<byte>, CancellationToken) #public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default)
See Stream..
method WriteAsync(byte[], int, int, CancellationToken) #
WriteAsync(byte[], int, int, CancellationToken) #public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
See Stream..
namespace StellaOps.Microservice.Validation
| Type | Kind | Description |
|---|---|---|
EndpointSchemaDefinition | record | Defines the schema information for an endpoint. |
IGeneratedSchemaProvider | interface | Interface implemented by the source-generated schema provider. |
IRequestSchemaValidator | interface | Validates JSON documents against JSON schemas. |
ISchemaRegistry | interface | Registry for JSON schemas associated with endpoints. |
RequestSchemaValidator | class | Validates JSON documents against JSON schemas using JsonSchema.Net. |
SchemaDirection | enum | Specifies the direction of schema validation. |
SchemaRegistry | class | Registry for JSON schemas with caching and ETag support. |
SchemaValidationError | record | Represents a single schema validation error. |
SchemaValidationException | class | Exception thrown when request or response body fails schema validation. |
ValidationProblemDetails | class | RFC 7807 Problem Details for schema validation failures. |
record EndpointSchemaDefinition
public sealed record EndpointSchemaDefinition
Defines the schema information for an endpoint. Generated at compile time by the source generator.
Parameters
Method: The HTTP method (GET, POST, etc.).Path: The endpoint path template.RequestSchemaJson: The JSON Schema for the request body, or null if not validated.ResponseSchemaJson: The JSON Schema for the response body, or null if not validated.ValidateRequest: Whether request validation is enabled.ValidateResponse: Whether response validation is enabled.
Members
| Member | Kind | Summary |
|---|---|---|
EndpointSchemaDefinition( | constructor | Defines the schema information for an endpoint. |
Method | property | The HTTP method (GET, POST, etc.). |
Path | property | The endpoint path template. |
RequestSchemaJson | property | The JSON Schema for the request body, or null if not validated. |
ResponseSchemaJson | property | The JSON Schema for the response body, or null if not validated. |
ValidateRequest | property | Whether request validation is enabled. |
ValidateResponse | property | Whether response validation is enabled. |
constructor EndpointSchemaDefinition(string, string, string, string, bool, bool) #
EndpointSchemaDefinition(string, string, string, string, bool, bool) #public EndpointSchemaDefinition(string Method, string Path, string? RequestSchemaJson, string? ResponseSchemaJson, bool ValidateRequest, bool ValidateResponse)
Defines the schema information for an endpoint. Generated at compile time by the source generator.
Parameters
Method: The HTTP method (GET, POST, etc.).Path: The endpoint path template.RequestSchemaJson: The JSON Schema for the request body, or null if not validated.ResponseSchemaJson: The JSON Schema for the response body, or null if not validated.ValidateRequest: Whether request validation is enabled.ValidateResponse: Whether response validation is enabled.
property Method #
Method #public string Method { get; init; }
The HTTP method (GET, POST, etc.).
property Path #
Path #public string Path { get; init; }
The endpoint path template.
property RequestSchemaJson #
RequestSchemaJson #public string? RequestSchemaJson { get; init; }
The JSON Schema for the request body, or null if not validated.
property ResponseSchemaJson #
ResponseSchemaJson #public string? ResponseSchemaJson { get; init; }
The JSON Schema for the response body, or null if not validated.
property ValidateRequest #
ValidateRequest #public bool ValidateRequest { get; init; }
Whether request validation is enabled.
property ValidateResponse #
ValidateResponse #public bool ValidateResponse { get; init; }
Whether response validation is enabled.
interface IGeneratedSchemaProvider
public interface IGeneratedSchemaProvider
Interface implemented by the source-generated schema provider. Provides access to schemas generated at compile time.
Members
| Member | Kind | Summary |
|---|---|---|
GetSchemaDefinitions( | method | Gets all endpoint schema definitions generated at compile time. |
method GetSchemaDefinitions() #
GetSchemaDefinitions() #IReadOnlyList<EndpointSchemaDefinition> GetSchemaDefinitions()
Gets all endpoint schema definitions generated at compile time.
Returns
A list of all endpoint schema definitions.
interface IRequestSchemaValidator
public interface IRequestSchemaValidator
Validates JSON documents against JSON schemas.
Members
| Member | Kind | Summary |
|---|---|---|
TryValidate( | method | Validates a JSON document against a schema. |
method TryValidate(JsonDocument, JsonSchema, out IReadOnlyList<SchemaValidationError>) #
TryValidate(JsonDocument, JsonSchema, out IReadOnlyList<SchemaValidationError>) #bool TryValidate(JsonDocument document, JsonSchema schema, out IReadOnlyList<SchemaValidationError> errors)
Validates a JSON document against a schema.
Parameters
document: The JSON document to validate.schema: The JSON schema to validate against.errors: When validation fails, contains the list of errors.
Returns
True if the document is valid, false otherwise.
interface ISchemaRegistry
public interface ISchemaRegistry
Registry for JSON schemas associated with endpoints. Provides compiled schemas for validation and raw text for documentation.
Members
| Member | Kind | Summary |
|---|---|---|
GetAllSchemas( | method | Gets all registered schema definitions. |
GetRequestSchema( | method | Gets the compiled JSON schema for an endpoint’s request. |
GetResponseSchema( | method | Gets the compiled JSON schema for an endpoint’s response. |
GetSchemaETag( | method | Gets the ETag for the schema (for HTTP caching). |
GetSchemaText( | method | Gets the raw schema text for documentation/publication. |
HasSchema( | method | Checks if an endpoint has a schema registered. |
method GetAllSchemas() #
GetAllSchemas() #IReadOnlyList<EndpointSchemaDefinition> GetAllSchemas()
Gets all registered schema definitions.
Returns
All endpoint schema definitions.
method GetRequestSchema(string, string) #
GetRequestSchema(string, string) #JsonSchema? GetRequestSchema(string method, string path)
Gets the compiled JSON schema for an endpoint’s request.
Parameters
method: The HTTP method.path: The endpoint path template.
Returns
The compiled schema, or null if no schema is registered.
method GetResponseSchema(string, string) #
GetResponseSchema(string, string) #JsonSchema? GetResponseSchema(string method, string path)
Gets the compiled JSON schema for an endpoint’s response.
Parameters
method: The HTTP method.path: The endpoint path template.
Returns
The compiled schema, or null if no schema is registered.
method GetSchemaETag(string, string, SchemaDirection) #
GetSchemaETag(string, string, SchemaDirection) #string? GetSchemaETag(string method, string path, SchemaDirection direction)
Gets the ETag for the schema (for HTTP caching).
Parameters
method: The HTTP method.path: The endpoint path template.direction: Whether to get request or response schema.
Returns
The ETag value, or null if no schema is registered.
method GetSchemaText(string, string, SchemaDirection) #
GetSchemaText(string, string, SchemaDirection) #string? GetSchemaText(string method, string path, SchemaDirection direction)
Gets the raw schema text for documentation/publication.
Parameters
method: The HTTP method.path: The endpoint path template.direction: Whether to get request or response schema.
Returns
The raw JSON schema text, or null if no schema is registered.
method HasSchema(string, string, SchemaDirection) #
HasSchema(string, string, SchemaDirection) #bool HasSchema(string method, string path, SchemaDirection direction)
Checks if an endpoint has a schema registered.
Parameters
method: The HTTP method.path: The endpoint path template.direction: Whether to check request or response schema.
Returns
True if a schema is registered.
class RequestSchemaValidator
public sealed class RequestSchemaValidator : IRequestSchemaValidator
Validates JSON documents against JSON schemas using JsonSchema.Net.
Members
| Member | Kind | Summary |
|---|---|---|
RequestSchemaValidator( | constructor | Creates a new request schema validator. |
TryValidate( | method | Validates a JSON document against a schema. |
constructor RequestSchemaValidator(ILogger<RequestSchemaValidator>) #
RequestSchemaValidator(ILogger<RequestSchemaValidator>) #public RequestSchemaValidator(ILogger<RequestSchemaValidator> logger)
Creates a new request schema validator.
method TryValidate(JsonDocument, JsonSchema, out IReadOnlyList<SchemaValidationError>) #
TryValidate(JsonDocument, JsonSchema, out IReadOnlyList<SchemaValidationError>) #public bool TryValidate(JsonDocument document, JsonSchema schema, out IReadOnlyList<SchemaValidationError> errors)
Validates a JSON document against a schema.
Parameters
document: The JSON document to validate.schema: The JSON schema to validate against.errors: When validation fails, contains the list of errors.
Returns
True if the document is valid, false otherwise.
enum SchemaDirection
public enum SchemaDirection
Specifies the direction of schema validation.
| Value | Description |
|---|---|
Request = 0 | Validates incoming request bodies. |
Response = 1 | Validates outgoing response bodies. |
class SchemaRegistry
public sealed class SchemaRegistry : ISchemaRegistry
Registry for JSON schemas with caching and ETag support. Follows the RiskProfileSchemaProvider pattern.
Members
| Member | Kind | Summary |
|---|---|---|
SchemaRegistry( | constructor | Creates a new schema registry. |
GetAllSchemas( | method | Gets all registered schema definitions. |
GetRequestSchema( | method | Gets the compiled JSON schema for an endpoint’s request. |
GetResponseSchema( | method | Gets the compiled JSON schema for an endpoint’s response. |
GetSchemaETag( | method | Gets the ETag for the schema (for HTTP caching). |
GetSchemaText( | method | Gets the raw schema text for documentation/publication. |
HasSchema( | method | Checks if an endpoint has a schema registered. |
constructor SchemaRegistry(ILogger<SchemaRegistry>, IGeneratedSchemaProvider) #
SchemaRegistry(ILogger<SchemaRegistry>, IGeneratedSchemaProvider) #public SchemaRegistry(ILogger<SchemaRegistry> logger, IGeneratedSchemaProvider? generatedProvider = null)
Creates a new schema registry.
Parameters
logger: The logger.generatedProvider: The source-generated schema provider, if available.
method GetAllSchemas() #
GetAllSchemas() #public IReadOnlyList<EndpointSchemaDefinition> GetAllSchemas()
Gets all registered schema definitions.
Returns
All endpoint schema definitions.
method GetRequestSchema(string, string) #
GetRequestSchema(string, string) #public JsonSchema? GetRequestSchema(string method, string path)
Gets the compiled JSON schema for an endpoint’s request.
Parameters
method: The HTTP method.path: The endpoint path template.
Returns
The compiled schema, or null if no schema is registered.
method GetResponseSchema(string, string) #
GetResponseSchema(string, string) #public JsonSchema? GetResponseSchema(string method, string path)
Gets the compiled JSON schema for an endpoint’s response.
Parameters
method: The HTTP method.path: The endpoint path template.
Returns
The compiled schema, or null if no schema is registered.
method GetSchemaETag(string, string, SchemaDirection) #
GetSchemaETag(string, string, SchemaDirection) #public string? GetSchemaETag(string method, string path, SchemaDirection direction)
Gets the ETag for the schema (for HTTP caching).
Parameters
method: The HTTP method.path: The endpoint path template.direction: Whether to get request or response schema.
Returns
The ETag value, or null if no schema is registered.
method GetSchemaText(string, string, SchemaDirection) #
GetSchemaText(string, string, SchemaDirection) #public string? GetSchemaText(string method, string path, SchemaDirection direction)
Gets the raw schema text for documentation/publication.
Parameters
method: The HTTP method.path: The endpoint path template.direction: Whether to get request or response schema.
Returns
The raw JSON schema text, or null if no schema is registered.
method HasSchema(string, string, SchemaDirection) #
HasSchema(string, string, SchemaDirection) #public bool HasSchema(string method, string path, SchemaDirection direction)
Checks if an endpoint has a schema registered.
Parameters
method: The HTTP method.path: The endpoint path template.direction: Whether to check request or response schema.
Returns
True if a schema is registered.
record SchemaValidationError
public sealed record SchemaValidationError
Represents a single schema validation error.
Parameters
InstanceLocation: JSON pointer to the invalid value (e.g., “/amount”).SchemaLocation: JSON pointer to the schema constraint (e.g., “#/properties/amount/minimum”).Message: Human-readable error message.Keyword: The JSON Schema keyword that failed (e.g., “required”, “minimum”, “type”).
Members
| Member | Kind | Summary |
|---|---|---|
SchemaValidationError( | constructor | Represents a single schema validation error. |
InstanceLocation | property | JSON pointer to the invalid value (e.g., “/amount”). |
Keyword | property | The JSON Schema keyword that failed (e.g., “required”, “minimum”, “type”). |
Message | property | Human-readable error message. |
SchemaLocation | property | JSON pointer to the schema constraint (e.g., “#/properties/amount/minimum”). |
constructor SchemaValidationError(string, string, string, string) #
SchemaValidationError(string, string, string, string) #public SchemaValidationError(string InstanceLocation, string SchemaLocation, string Message, string Keyword)
Represents a single schema validation error.
Parameters
InstanceLocation: JSON pointer to the invalid value (e.g., “/amount”).SchemaLocation: JSON pointer to the schema constraint (e.g., “#/properties/amount/minimum”).Message: Human-readable error message.Keyword: The JSON Schema keyword that failed (e.g., “required”, “minimum”, “type”).
property InstanceLocation #
InstanceLocation #public string InstanceLocation { get; init; }
JSON pointer to the invalid value (e.g., “/amount”).
property Keyword #
Keyword #public string Keyword { get; init; }
The JSON Schema keyword that failed (e.g., “required”, “minimum”, “type”).
property Message #
Message #public string Message { get; init; }
Human-readable error message.
property SchemaLocation #
SchemaLocation #public string SchemaLocation { get; init; }
JSON pointer to the schema constraint (e.g., “#/properties/amount/minimum”).
class SchemaValidationException
public sealed class SchemaValidationException : Exception
Exception thrown when request or response body fails schema validation.
Members
| Member | Kind | Summary |
|---|---|---|
SchemaValidationException( | constructor | Creates a new schema validation exception. |
Direction | property | Gets whether this was request or response validation. |
EndpointMethod | property | Gets the HTTP method of the endpoint. |
EndpointPath | property | Gets the endpoint path where validation failed. |
Errors | property | Gets the list of validation errors. |
constructor SchemaValidationException(string, string, SchemaDirection, IReadOnlyList<SchemaValidationError>) #
SchemaValidationException(string, string, SchemaDirection, IReadOnlyList<SchemaValidationError>) #public SchemaValidationException(string endpointMethod, string endpointPath, SchemaDirection direction, IReadOnlyList<SchemaValidationError> errors)
Creates a new schema validation exception.
property Direction #
Direction #public SchemaDirection Direction { get; }
Gets whether this was request or response validation.
property EndpointMethod #
EndpointMethod #public string EndpointMethod { get; }
Gets the HTTP method of the endpoint.
property EndpointPath #
EndpointPath #public string EndpointPath { get; }
Gets the endpoint path where validation failed.
property Errors #
Errors #public IReadOnlyList<SchemaValidationError> Errors { get; }
Gets the list of validation errors.
class ValidationProblemDetails
public sealed class ValidationProblemDetails
RFC 7807 Problem Details for schema validation failures. Returns HTTP 422 Unprocessable Entity.
Members
| Member | Kind | Summary |
|---|---|---|
ValidationProblemDetails( | constructor | Creates an instance of Validation. |
SchemaValidationType | constant | The problem type of a schema validation failure: a URN tied to no domain, like every Router problem type (urn:stellaops:router:.). |
Detail | property | A human-readable explanation specific to this occurrence. |
Errors | property | The list of validation errors. |
Instance | property | A URI reference identifying the specific occurrence (the endpoint path). |
Status | property | The HTTP status code (422). |
Title | property | A short, human-readable summary of the problem. |
TraceId | property | The trace/correlation ID for distributed tracing. |
Type | property | A URI reference identifying the problem type. |
Create( | method | Creates a ValidationProblemDetails for schema validation failures. |
ToRawResponse( | method | Converts this problem details to a RawResponse. |
constructor ValidationProblemDetails() #
ValidationProblemDetails() #public ValidationProblemDetails()
Creates an instance of Validation.
constant SchemaValidationType #
SchemaValidationType #public const string SchemaValidationType = "urn:stellaops:router:schema-validation"
The problem type of a schema validation failure: a URN tied to no domain, like every Router problem type (urn:stellaops:router:.).
property Detail #
Detail #public string? Detail { get; init; }
A human-readable explanation specific to this occurrence.
property Errors #
Errors #public IReadOnlyList<SchemaValidationError> Errors { get; init; }
The list of validation errors.
property Instance #
Instance #public string? Instance { get; init; }
A URI reference identifying the specific occurrence (the endpoint path).
property Status #
Status #public int Status { get; init; }
The HTTP status code (422).
property Title #
Title #public string Title { get; init; }
A short, human-readable summary of the problem.
property TraceId #
TraceId #public string? TraceId { get; init; }
The trace/correlation ID for distributed tracing.
property Type #
Type #public string Type { get; init; }
A URI reference identifying the problem type.
method Create(string, string, SchemaDirection, IReadOnlyList<SchemaValidationError>, string) #
Create(string, string, SchemaDirection, IReadOnlyList<SchemaValidationError>, string) #public static ValidationProblemDetails Create(string method, string path, SchemaDirection direction, IReadOnlyList<SchemaValidationError> errors, string? correlationId = null)
Creates a ValidationProblemDetails for schema validation failures.
Parameters
method: The HTTP method.path: The endpoint path.direction: Request or response validation.errors: The validation errors.correlationId: Optional correlation ID.
method ToRawResponse() #
ToRawResponse() #public RawResponse ToRawResponse()
Converts this problem details to a RawResponse.