grpcwire

package
v0.2.0-beta.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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

func Dial(addr string, options ...Option) (*Conn, error)

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) Close

func (conn *Conn) Close() error

Close releases the connection's idle transport state.

func (*Conn) Invoke

func (conn *Conn) Invoke(ctx context.Context, fullMethod string, req []byte) ([]byte, error)

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

func WithCallTimeout(timeout time.Duration) Option

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.

func (*RPCError) Error

func (err *RPCError) Error() string

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL