Documentation
¶
Overview ¶
Package transport defines the transport abstraction every handwritten RPC protocol sits on.
The in-tree implementation is an in-process memory pipe used by tests and the conformance harness. Real gRPC / named pipe / Unix socket transports belong to the A4 Plugin Host and only need to satisfy Transport here; the service client/server layers in sdk/go/cloudpath/v1/* are transport-agnostic.
The Message envelope is intentionally minimal and language-neutral: every RPC call gets a CallID and, when it starts a stream, a Method. Body carries the JSON-marshaled service message exactly as the handwritten Go structs encode it.
Index ¶
Constants ¶
const ( KindUnary uint8 = 1 // unary request; expects exactly one terminal frame KindResponse uint8 = 2 // terminal unary response (Body set, Err nil) KindStreamReq uint8 = 3 // open a stream; expects KindStreamMsg* then terminal frame KindStreamMsg uint8 = 4 // stream message in either direction KindStreamEnd uint8 = 5 // half-close from the sender; receiver keeps its send side KindStreamEndTerm uint8 = 6 // terminal frame closing a stream for both sides KindStreamCancel uint8 = 7 // client cancels the whole call )
Frame kinds. Keep in sync with sdk/go/rpc aliases.
Variables ¶
var ErrClosed = errors.New("cloudpath transport: closed")
ErrClosed is returned by Send/Recv once the transport is closed.
Functions ¶
Types ¶
type Message ¶
type Message struct {
CallID uint64 `json:"call_id"`
Kind uint8 `json:"kind"`
Method string `json:"method,omitempty"`
Body []byte `json:"body,omitempty"`
Err *status.Status `json:"error,omitempty"`
}
Message is the wire envelope carried by a Transport.
type Transport ¶
type Transport interface {
// Send delivers one message. It must block while the peer's receive
// buffer is full (backpressure) and return ctx.Err on cancellation or
// ErrClosed after Close.
Send(ctx context.Context, m Message) error
// Recv returns the next message in order, blocks when none is queued,
// and returns io.EOF or ErrClosed once the transport shuts down.
Recv(ctx context.Context) (Message, error)
// Close tears the transport down and unblocks both directions.
Close() error
}
Transport is a duplex, ordered, backpressured message channel. It carries one RPC connection between a plugin process and its host. Implementations may be named pipes, Unix sockets, loopback TCP, or the in-memory pipe in this package; the protocol layers must not depend on which one is used.