blackbull.grpc.asgi¶
blackbull.grpc.asgi
¶
gRPC call semantics over the existing HTTP/2 receive/send bridge.
Status is reported in trailers; reuse stream isolation and flow control rather than introducing another protocol actor.
GrpcContext
¶
Per-call metadata, peer, deadline and response status/metadata controls for raw-byte handlers.
invocation_metadata()
¶
Return the request fields as (name, value) pairs with lowercase
names and no pseudo-headers — grpcio's
ServicerContext.invocation_metadata.
metadata(name, default=b'')
¶
Return the first request field named name (any case), or default.
peer()
¶
Return the client address as grpcio formats it (ipv4:host:port /
ipv6:[host]:port), or '' when the transport did not supply one.
send_initial_metadata(metadata)
async
¶
Send response leading metadata now (the initial HTTP/2 HEADERS),
before the first response message — grpcio's
ServicerContext.send_initial_metadata.
Optional: if never called, the response HEADERS are still emitted lazily
(just before the first message, or with the trailers for an empty
response). Calling it flushes them early with metadata attached — used
to hand the client leading metadata (auth challenges, stream ids) up
front. Raises ValueError once the HEADERS have already gone
out (grpcio's "initial metadata no longer allowed").
time_remaining()
¶
Seconds left until the call deadline (never negative), or None
when the client set no grpc-timeout — grpcio's
ServicerContext.time_remaining. Lets a handler shed work it cannot
finish in time.
trailing_metadata()
¶
The trailing metadata set so far, as a copy — so a helper composes with what the handler already set instead of clobbering it.
serve_grpc(registry, conn, receive, send)
async
¶
Serve any of the four gRPC call shapes for conn.
Report handler and protocol failures as gRPC status.