Skip to main content

Module rpc

Module rpc 

Source
Expand description

RPC method registration: plugins expose methods that PHP workers can invoke on the master in-process (via the folk_call() native function).

Two shapes of method exist:

  • Unary (RpcRegistrar) — one request Bytes → one response Bytes, driven by the synchronous folk_call bridge.
  • Streaming (StreamRegistrar, phase 88b) — one open → a stream of messages in either or both directions, driven by the handle-based blocking bridge (folk_stream_open/recv/send/close). The handler returns a StreamConn the bridge blocking-drains one message at a time.

Structs§

RpcMethodDef
Static description of an RPC method (advertised at server start; used for introspection / documentation).
StreamConn
A live stream connection returned by a StreamHandler. The transport plugin (e.g. folk-plugin-grpc) adapts its own stream type (tonic Streaming) into this transport-agnostic pair; the bridge in folk-ext drives it.

Traits§

RpcRegistrar
Allows plugins to register RPC method handlers at boot.
StreamRegistrar
Allows plugins to register streaming method handlers at boot. Additive counterpart to RpcRegistrar; folk-core provides the concrete impl.

Type Aliases§

BoxFuture
Boxed future returned by an RPC handler.
InboundStream
Boxed inbound message stream. The bridge blocking-drains it one item at a time (folk_stream_recv → Some(bytes) per item, None at end-of-stream).
OutboundSender
Outbound message channel for client-streaming / bidi: the bridge pushes PHP-sent messages here (folk_stream_send), closing it half-closes the send side (folk_stream_close_send). tokio::sync::mpsc gives natural backpressure.
RpcHandler
Type alias for an RPC handler: takes raw request bytes, returns raw response bytes.
StreamHandler
A streaming handler: given the initial request bytes, opens a StreamConn.
StreamItem
One inbound message of a stream: raw response Bytes, or an error carrying a gRPC-style status the bridge surfaces to PHP as an exception.