Documentation
¶
Overview ¶
Package drpc is a light replacement for gprc.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Error = errs.Class("drpc") InternalError = errs.Class("internal error") ProtocolError = errs.Class("protocol error") ClosedError = errs.Class("closed") )
These error classes represent some common errors that drpc generates.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn interface {
// Close closes the connection.
Close() error
// Closed returns a channel that is closed if the connection is definitely closed.
Closed() <-chan struct{}
// Invoke issues a unary RPC to the remote. Only one Invoke or Stream may be
// open at once.
Invoke(ctx context.Context, rpc string, enc Encoding, in, out Message) error
// NewStream starts a stream with the remote. Only one Invoke or Stream may be
// open at once.
NewStream(ctx context.Context, rpc string, enc Encoding) (Stream, error)
}
Conn represents a client connection to a server.
type Description ¶
type Description interface {
// NumMethods returns the number of methods available.
NumMethods() int
// Method returns the information about the nth method along with a handler
// to invoke it. The method interface that it returns is expected to be
// a method expression like `(*Type).HandlerName`.
Method(n int) (rpc string, encoding Encoding, receiver Receiver, method interface{}, ok bool)
}
Description is the interface implemented by things that can be registered by a Server.
type Encoding ¶ added in v0.0.18
type Encoding interface {
// Marshal returns the encoded form of msg.
Marshal(msg Message) ([]byte, error)
// Unmarshal reads the encoded form of some Message into msg.
// The buf is expected to contain only a single complete Message.
Unmarshal(buf []byte, msg Message) error
}
Encoding represents a way to marshal/unmarshal Message types.
type Handler ¶
type Handler interface {
// HandleRPC executes the RPC identified by the rpc string using the stream to
// communicate with the remote.
HandleRPC(stream Stream, rpc string) (err error)
}
Handler handles streams and RPCs dispatched to it by a Server.
type Message ¶
type Message interface{}
Message is a protobuf message. It is expected to be used with an Encoding. This exists so that one can use whatever protobuf library/runtime they want.
type Mux ¶ added in v0.0.10
type Mux interface {
// Register marks that the description should dispatch RPCs that it describes to
// the provided srv.
Register(srv interface{}, desc Description) error
}
Mux is a type that can have an implementation and a Description registered with it.
type Receiver ¶ added in v0.0.10
type Receiver = func(srv interface{}, ctx context.Context, in1, in2 interface{}) (out Message, err error)
Receiver is invoked by a server for a given RPC.
type Stream ¶
type Stream interface {
// Context returns the context associated with the stream. It is canceled
// when the Stream is closed and no more messages will ever be sent or
// received on it.
Context() context.Context
// MsgSend sends the Message to the remote.
MsgSend(msg Message, enc Encoding) error
// MsgRecv receives a Message from the remote.
MsgRecv(msg Message, enc Encoding) error
// CloseSend signals to the remote that we will no longer send any messages.
CloseSend() error
// Close closes the stream.
Close() error
}
Stream is a bi-directional stream of messages to some other party.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
protoc-gen-go-drpc
command
protoc-gen-go-drpc generates DRPC code for protobuf services.
|
protoc-gen-go-drpc generates DRPC code for protobuf services. |
|
Package drpccache implements per stream cache for drpc.
|
Package drpccache implements per stream cache for drpc. |
|
Package drpcconn creates a drpc client connection from a transport.
|
Package drpcconn creates a drpc client connection from a transport. |
|
Package drpcctx has helpers to interact with context.Context.
|
Package drpcctx has helpers to interact with context.Context. |
|
Package drpcdebug provides helpers for debugging.
|
Package drpcdebug provides helpers for debugging. |
|
Package drpcenc holds some helper functions for encoding messages.
|
Package drpcenc holds some helper functions for encoding messages. |
|
Package drpcerr lets one associate error codes with errors.
|
Package drpcerr lets one associate error codes with errors. |
|
Package drpchttp implements a net/http handler for unitary RPCs.
|
Package drpchttp implements a net/http handler for unitary RPCs. |
|
Package drpcmanager reads packets from a transport to make streams.
|
Package drpcmanager reads packets from a transport to make streams. |
|
Package drpcmetadata define the structure of the metadata supported by drpc library.
|
Package drpcmetadata define the structure of the metadata supported by drpc library. |
|
Package drpcmigrate provides tools to support drpc concurrently alongside gRPC on the same ports.
|
Package drpcmigrate provides tools to support drpc concurrently alongside gRPC on the same ports. |
|
Package drpcmux is a handler to dispatch rpcs to implementations.
|
Package drpcmux is a handler to dispatch rpcs to implementations. |
|
Package drpcpool is a simple connection pool for clients.
|
Package drpcpool is a simple connection pool for clients. |
|
Package drpcserver allows one to execute registered rpcs.
|
Package drpcserver allows one to execute registered rpcs. |
|
Package drpcsignal holds a helper type to signal errors.
|
Package drpcsignal holds a helper type to signal errors. |
|
Package drpcstats contatins types for stat collection.
|
Package drpcstats contatins types for stat collection. |
|
Package drpcstream sends protobufs using the dprc wire protocol.
|
Package drpcstream sends protobufs using the dprc wire protocol. |
|
Package drpctest provides test related helpers.
|
Package drpctest provides test related helpers. |
|
Package drpcwire provides low level helpers for the drpc wire protocol.
|
Package drpcwire provides low level helpers for the drpc wire protocol. |
|
examples
|
|
|
drpc
module
|
|
|
drpc_and_http
module
|
|
|
grpc
module
|
|
|
grpc_and_drpc
module
|
|
|
opentelemetry
module
|
|
|
internal
|
|
|
drpcopts
Package drpcopts contains internal options.
|
Package drpcopts contains internal options. |
|
backcompat
module
|
|
|
backcompat/newservice
module
|
|
|
backcompat/newservicedefs
module
|
|
|
backcompat/oldservice
module
|
|
|
backcompat/oldservicedefs
module
|
|
|
backcompat/servicedefs
module
|
|
|
grpccompat
module
|
|
|
integration
module
|
|
|
twirpcompat
module
|
