Table of Contents

Class GrpcReflectionService

Namespace
Virtufin.Api.Services
Assembly
Virtufin.Api.dll

Provides gRPC reflection functionality including service discovery, method schema retrieval, and dynamic gRPC invocation based on reflection data.

public class GrpcReflectionService
Inheritance
GrpcReflectionService
Inherited Members

Constructors

GrpcReflectionService(GrpcChannelPool, ILogger<GrpcReflectionService>, IConfiguration)

public GrpcReflectionService(GrpcChannelPool channelPool, ILogger<GrpcReflectionService> logger, IConfiguration configuration)

Parameters

channelPool GrpcChannelPool
logger ILogger<GrpcReflectionService>
configuration IConfiguration

Methods

ExecuteCallAsync(string, string, byte[], Dictionary<string, string>?, CancellationToken)

Executes a gRPC call with raw protobuf bytes (passthrough, no conversion).

public Task<GrpcCallResult> ExecuteCallAsync(string serviceName, string methodName, byte[] requestData, Dictionary<string, string>? metadata = null, CancellationToken cancellationToken = default)

Parameters

serviceName string

The target service name.

methodName string

The method to invoke.

requestData byte[]

The raw protobuf request data as bytes.

metadata Dictionary<string, string>

Optional metadata headers.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<GrpcCallResult>

The result of the gRPC call with raw protobuf bytes.

ExecuteCallAsync(string, string, string, Dictionary<string, string>?, CancellationToken)

Executes a gRPC call by name, using reflection for type information.

public Task<GrpcCallResult> ExecuteCallAsync(string serviceName, string methodName, string requestJson, Dictionary<string, string>? metadata = null, CancellationToken cancellationToken = default)

Parameters

serviceName string

The target service name.

methodName string

The method to invoke.

requestJson string

The request payload as JSON.

metadata Dictionary<string, string>

Optional metadata headers.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<GrpcCallResult>

The result of the gRPC call.

GetFileDescriptorProtosAsync(string, CancellationToken)

Retrieves the raw file descriptor protos for a service.

public Task<List<ByteString>> GetFileDescriptorProtosAsync(string serviceName, CancellationToken cancellationToken = default)

Parameters

serviceName string

The name of the service.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<List<ByteString>>

List of ByteString containing the descriptor protos.

GetMethodSchemaAsync(string, string, string?, CancellationToken)

Gets the schema for a specific method including input/output types and field definitions.

public Task<MethodSchema?> GetMethodSchemaAsync(string serviceName, string methodName, string? type = null, CancellationToken cancellationToken = default)

Parameters

serviceName string

The name of the service.

methodName string

The name of the method.

type string

Optional type name for schema resolution.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<MethodSchema>

The method schema or null if not found.

GetMethodsAsync(string, CancellationToken)

Retrieves all methods for a given service using gRPC reflection.

public Task<List<ServiceMethodInfo>> GetMethodsAsync(string serviceName, CancellationToken cancellationToken = default)

Parameters

serviceName string

The name of the service to query.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<List<ServiceMethodInfo>>

A list of ServiceMethodInfo describing each method.

InvalidateAllCaches()

Invalidates all service descriptor caches.

public void InvalidateAllCaches()

InvalidateCache(string)

Invalidates the reflection descriptor cache for a specific service. Forces a reload of proto schemas on the next access.

public void InvalidateCache(string serviceName)

Parameters

serviceName string

The service name to invalidate.