Class GatewayService
Implementation of the gRPC Gateway service: service discovery and method
invocation. Subscribing is Pubsub.Subscribe (see PubsubService).
public class GatewayService : Gateway.GatewayBase
- Inheritance
-
Gateway.GatewayBaseGatewayService
- Inherited Members
Constructors
GatewayService(GrpcReflectionService, ServicesConfiguration, ILogger<GatewayService>, GatewayResiliencePipeline, PayloadSchemaRegistry)
Creates a new GatewayService instance.
public GatewayService(GrpcReflectionService reflectionService, ServicesConfiguration config, ILogger<GatewayService> logger, GatewayResiliencePipeline resilience, PayloadSchemaRegistry payloadSchemas)
Parameters
reflectionServiceGrpcReflectionServiceThe gRPC reflection service for method discovery.
configServicesConfigurationThe services configuration containing registered services.
loggerILogger<GatewayService>The logger for recording service events.
resilienceGatewayResiliencePipelineThe Dapr resilience pipeline for wrapping gateway invocations.
payloadSchemasPayloadSchemaRegistryThe payload schema registry.
Methods
GetMethodSchema(GetMethodSchemaRequest, ServerCallContext)
Gets the schema for a specific method including input/output types and field definitions.
public override Task<GetMethodSchemaResponse> GetMethodSchema(GetMethodSchemaRequest request, ServerCallContext context)
Parameters
requestGetMethodSchemaRequestThe get method schema request containing service, method, and schema type.
contextServerCallContextThe server call context.
Returns
- Task<GetMethodSchemaResponse>
The method schema including field definitions.
GetPayloadSchema(GetPayloadSchemaRequest, ServerCallContext)
A payload schema by content type or hash.
public override Task<PayloadSchema> GetPayloadSchema(GetPayloadSchemaRequest request, ServerCallContext context)
Parameters
requestGetPayloadSchemaRequestcontextServerCallContext
Returns
- Task<PayloadSchema>
Invoke(InvokeRequest, ServerCallContext)
Invokes a method on a backend service using raw protobuf bytes.
public override Task<InvokeResponse> Invoke(InvokeRequest request, ServerCallContext context)
Parameters
requestInvokeRequestThe invoke request containing service name, method name, and request data.
contextServerCallContextThe server call context.
Returns
- Task<InvokeResponse>
The invoke response containing success status and response data.
InvokeJson(InvokeJsonRequest, ServerCallContext)
Invokes a method on a backend service using JSON request/response data. This is the recommended method for most use cases.
public override Task<InvokeJsonResponse> InvokeJson(InvokeJsonRequest request, ServerCallContext context)
Parameters
requestInvokeJsonRequestThe invoke JSON request containing service name, method name, and JSON request data.
contextServerCallContextThe server call context.
Returns
- Task<InvokeJsonResponse>
The invoke JSON response containing success status and JSON response data.
InvokeJsonStream(InvokeJsonRequest, IServerStreamWriter<InvokeJsonResponse>, ServerCallContext)
A backend's server-streaming method, relayed as JSON (openspec api-gateway, Streaming JSON Invocation): each backend message is one response, the stream ends when the backend's does, and the caller canceling cancels the backend call. Not retried by the resilience pipeline: a stream that broke is the caller's to reopen.
public override Task InvokeJsonStream(InvokeJsonRequest request, IServerStreamWriter<InvokeJsonResponse> responseStream, ServerCallContext context)
Parameters
requestInvokeJsonRequestresponseStreamIServerStreamWriter<InvokeJsonResponse>contextServerCallContext
Returns
ListMethods(ListMethodsRequest, ServerCallContext)
Lists all methods available for a specific service.
public override Task<ListMethodsResponse> ListMethods(ListMethodsRequest request, ServerCallContext context)
Parameters
requestListMethodsRequestThe list methods request containing the service name.
contextServerCallContextThe server call context.
Returns
- Task<ListMethodsResponse>
A list of method descriptors.
ListPayloadSchemas(ListPayloadSchemasRequest, ServerCallContext)
Every registered payload content type, without the schemas' bytes.
public override Task<ListPayloadSchemasResponse> ListPayloadSchemas(ListPayloadSchemasRequest request, ServerCallContext context)
Parameters
requestListPayloadSchemasRequestcontextServerCallContext
Returns
- Task<ListPayloadSchemasResponse>
ListServices(ListServicesRequest, ServerCallContext)
Lists all services registered with the gateway.
public override Task<ListServicesResponse> ListServices(ListServicesRequest request, ServerCallContext context)
Parameters
requestListServicesRequestThe list services request.
contextServerCallContextThe server call context.
Returns
- Task<ListServicesResponse>
A list of service names.
RegisterPayloadSchema(RegisterPayloadSchemaRequest, ServerCallContext)
Registers the schema of a binary payload a producer emits (openspec api-gateway, Payload Schema Registry).
public override Task<RegisterPayloadSchemaResponse> RegisterPayloadSchema(RegisterPayloadSchemaRequest request, ServerCallContext context)
Parameters
requestRegisterPayloadSchemaRequestcontextServerCallContext
Returns
- Task<RegisterPayloadSchemaResponse>