Class GrpcMockHostingExtension

Namespace
Kuestenlogik.Bowire.Protocol.Grpc.Mock
Assembly
Kuestenlogik.Bowire.Protocol.Grpc.dll

gRPC plugin's hosting extension. Three responsibilities the mock server delegates here when the loaded recording contains gRPC steps:

  1. Force HTTP/2 hosting (gRPC requires it; plaintext HTTP/1.1 and HTTP/2 can't share a port without TLS+ALPN).
  2. Build a per-recording ReflectionServiceImpl from the captured FileDescriptorSets and register it in DI.
  3. Map the gRPC reflection endpoint so a peer Bowire workbench can auto-discover the mocked services without the user supplying .proto files out of band.
public sealed class GrpcMockHostingExtension : IBowireMockHostingExtension
Inheritance
GrpcMockHostingExtension
Implements
Inherited Members

Constructors

GrpcMockHostingExtension()

public GrpcMockHostingExtension()

Properties

Id

Stable id, lower-case, matching the protocol the extension belongs to (e.g. "grpc"). Surfaced in logs only — the host never dispatches by id, it always asks each extension in turn.

public string Id { get; }

Property Value

string

Methods

ConfigureServices(IServiceCollection, BowireRecording, ILoggerFactory)

Register DI services the protocol-specific mock surface needs. Called during MockServer service-collection setup, before the host builds the application. gRPC uses this to add AddGrpc() + a per-recording ReflectionServiceImpl.

public void ConfigureServices(IServiceCollection services, BowireRecording recording, ILoggerFactory loggerFactory)

Parameters

services IServiceCollection
recording BowireRecording
loggerFactory ILoggerFactory

MapEndpoints(IEndpointRouteBuilder, BowireRecording)

Map protocol-specific endpoints. Called inside the mock host's UseEndpoints block, after the recording-replay middleware is mounted. gRPC uses this to map the reflection service so peer workbenches can auto-discover.

public void MapEndpoints(IEndpointRouteBuilder endpoints, BowireRecording recording)

Parameters

endpoints IEndpointRouteBuilder
recording BowireRecording

RequiresHttp2(BowireRecording)

Return true when at least one step in the recording needs HTTP/2 hosting. The mock server picks the highest-required protocol level across all extensions before configuring Kestrel. gRPC says yes when the recording contains gRPC steps; REST/SignalR/SSE say no.

public bool RequiresHttp2(BowireRecording recording)

Parameters

recording BowireRecording

Returns

bool

Remarks

Only steps that can actually serve something over the gRPC wire count: unary wire bytes (responseBinary), streaming frames (receivedMessages), or a reflection-servable schemaDescriptor. A grpc step with none of those (hand- authored recording, pre-v2 capture) has nothing to serve, and forcing the whole port to plaintext HTTP/2 for it would break every HTTP/1.1 replay in a mixed recording (GraphQL / SSE / REST steps become unreachable for ordinary clients; see the protocol note in MockServer).