Interface IGatewayApi
The gateway itself: service discovery and typed dispatch to a backend service.
public interface IGatewayApi
Methods
GetPayloadSchemaAsync(GetPayloadSchemaRequest, CancellationToken)
A payload schema by content type (its current one) or by hash; null when there is none (or no gateway).
Task<PayloadSchema?> GetPayloadSchemaAsync(GetPayloadSchemaRequest request, CancellationToken cancellationToken = default)
Parameters
requestGetPayloadSchemaRequestcancellationTokenCancellationToken
Returns
- Task<PayloadSchema>
InvokeAsync<TRequest, TResponse>(string, string, TRequest, MessageParser<TResponse>, TimeSpan?, CancellationToken)
Calls method on the backend service through
Gateway.Invoke, protobuf bytes in and out. A backend failure the gateway
reports in-band (its status/message) is thrown as
GatewayInvokeException. No JSON and no reflection: safe under
NativeAOT, unlike the dynamic client.service.Method(dictionary) form.
parser is the response message's Parser (e.g.
CreateWorkerResponse.Parser); a null timeout
leaves the deadline to the gateway's default (30 s).
Task<TResponse> InvokeAsync<TRequest, TResponse>(string service, string method, TRequest request, MessageParser<TResponse> parser, TimeSpan? timeout = null, CancellationToken cancellationToken = default) where TRequest : IMessage where TResponse : IMessage<TResponse>
Parameters
servicestringmethodstringrequestTRequestparserMessageParser<TResponse>timeoutTimeSpan?cancellationTokenCancellationToken
Returns
- Task<TResponse>
Type Parameters
TRequestTResponse
ListPayloadSchemasAsync(CancellationToken)
Every registered payload content type, without the schemas' bytes; empty without a gateway.
Task<IReadOnlyList<PayloadSchemaEntry>> ListPayloadSchemasAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
- Task<IReadOnlyList<PayloadSchemaEntry>>
ListServicesAsync(CancellationToken)
Task<List<string>> ListServicesAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
RegisterPayloadSchemaAsync(PayloadSchema, CancellationToken)
Registers the schema of a binary payload the caller emits (openspec api-gateway, Payload Schema Registry); registering the same schema again changes nothing. The default does nothing: an in-process host has no gateway registry. ApiClient registers with the gateway.
Task<RegisterPayloadSchemaResponse> RegisterPayloadSchemaAsync(PayloadSchema schema, CancellationToken cancellationToken = default)
Parameters
schemaPayloadSchemacancellationTokenCancellationToken
Returns
- Task<RegisterPayloadSchemaResponse>