Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrStreamClosed = errors.New("stream closed")
)
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is responsible for registering RPC request handlers for RPC types.
func NewHandler ¶
func NewHandler() *Handler
func (*Handler) Find ¶
func (h *Handler) Find(rpcType Type) (HandlerFunc, bool)
Find looks up the handler for the given RPC type.
func (*Handler) Register ¶
func (h *Handler) Register(rpcType Type, handler HandlerFunc)
Register adds a new handler for the given RPC request type.
type HandlerFunc ¶
HandlerFunc handles the given request message and returns a response.
type Stream ¶
type Stream interface { Addr() string RPC(ctx context.Context, rpcType Type, req []byte) ([]byte, error) Monitor( ctx context.Context, interval time.Duration, timeout time.Duration, ) error Close() error }
Stream represents a bi-directional RPC stream between two peers. Either peer can send an RPC request to the other.
The stream uses the underlying bi-directional connection to send RPC requests, and multiplexes multiple concurrent request/response RPCs on the same connection.
Incoming RPC requests are handled in their own goroutine to avoid blocking the stream.
Click to show internal directories.
Click to hide internal directories.