Class GatewayService
Implementation of the gRPC Gateway service. Provides service discovery, method invocation, and event subscription capabilities.
public class GatewayService : Gateway.GatewayBase
- Inheritance
-
Gateway.GatewayBaseGatewayService
- Inherited Members
Constructors
GatewayService(GrpcReflectionService, ServicesConfiguration, ILogger<GatewayService>, DaprPublishSubscribeClient, DaprResiliencePipeline)
Creates a new GatewayService instance.
public GatewayService(GrpcReflectionService reflectionService, ServicesConfiguration config, ILogger<GatewayService> logger, DaprPublishSubscribeClient pubsubClient, DaprResiliencePipeline resilience)
Parameters
reflectionServiceGrpcReflectionServiceThe gRPC reflection service for method discovery.
configServicesConfigurationThe services configuration containing registered services.
loggerILogger<GatewayService>The logger for recording service operations.
pubsubClientDaprPublishSubscribeClientThe Dapr pub/sub client for event streaming.
resilienceDaprResiliencePipelineThe Dapr resilience pipeline for wrapping gateway invocations.
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.
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.
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.
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.
Subscribe(SubscribeRequest, IServerStreamWriter<TopicEventRequest>, ServerCallContext)
Subscribes to events from specified services and topics. Returns a stream of TopicEventRequest messages.
public override Task Subscribe(SubscribeRequest request, IServerStreamWriter<TopicEventRequest> responseStream, ServerCallContext context)
Parameters
requestSubscribeRequestThe subscribe request containing service, topic, and event type filters.
responseStreamIServerStreamWriter<TopicEventRequest>The stream writer for sending events to the client.
contextServerCallContextThe server call context.
Returns
- Task
A task that completes when the subscription is cancelled.