Documentation
¶
Overview ¶
Package grpcwire is a minimal gRPC-over-h2c client for the Android agent.
The agent serves the fixed 12-rpc FlowBatonDriver surface (proto/flowbaton_android.proto) over plaintext HTTP/2 with prior knowledge. This package owns the gRPC frame and trailer layer over x/net/http2 h2c; x/net/http2 handles HPACK and HTTP/2 state. Messages cross this API as raw protobuf bytes, with encoding owned by the caller.
Error split per specs/04-wire-protocols.md §1: UNAVAILABLE (14) and DEADLINE_EXCEEDED (4) are transport death, like a dial failure or a broken stream; every other non-zero grpc-status is a modelled failure carrying the agent's error-type / error-message / error-cause trailers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a client connection to one agent.
func Dial ¶
Dial prepares a connection to a plaintext HTTP/2 (h2c, prior knowledge) gRPC server at addr ("host:port"). The underlying transport connects lazily, on the first Invoke.
func (*Conn) Invoke ¶
Invoke performs one unary RPC. fullMethod is the gRPC path, like "/flowbaton_android.FlowBatonDriver/deviceInfo"; req and the reply are raw protobuf message bytes.
func (*Conn) InvokeClientStream ¶
func (conn *Conn) InvokeClientStream( ctx context.Context, fullMethod string, msgs <-chan []byte, ) ([]byte, error)
InvokeClientStream performs one client-streaming RPC, sending every message received from msgs in order and half-closing when msgs closes. The single reply arrives after the stream ends.
type Option ¶
type Option func(*Conn)
Option customizes a connection at dial time.
func WithCallTimeout ¶
WithCallTimeout replaces the default per-call deadline applied when the caller's context has none.
type RPCError ¶
type RPCError struct {
Code int
Message string
ErrorType string
ErrorMessage string
ErrorCause string
}
RPCError is a modelled failure: the server answered with a non-zero grpc-status other than the two transport-death ones. The three error-* fields are the agent's exception trailers from spec 04 §1.
type TransportError ¶
type TransportError struct {
// Op is what was being attempted, normally the full method.
Op string
// Code is the grpc-status when death arrived as one (4 or 14); 0 otherwise.
Code int
// Message is the grpc-message or a wire-level diagnosis.
Message string
// Err is the underlying transport error, when one exists.
Err error
}
TransportError is the connection dying rather than the server modelling a failure: dial and stream errors, a missed deadline, a malformed wire, a reply with no grpc-status at all, and the UNAVAILABLE / DEADLINE_EXCEEDED statuses. Retrying it means re-establishing the transport, not re-sending the same call on the same channel.
func (*TransportError) Error ¶
func (err *TransportError) Error() string
func (*TransportError) Unwrap ¶
func (err *TransportError) Unwrap() error