Documentation ¶
Index ¶
- Variables
- type DialerFn
- type Handler
- type Request
- type Response
- type Server
- type StreamLayer
- func (l *StreamLayer) Accept() (net.Conn, error)
- func (l *StreamLayer) Addr() net.Addr
- func (l *StreamLayer) Close() error
- func (l *StreamLayer) Dial(address string, timeout time.Duration) (net.Conn, error)
- func (l *StreamLayer) DialWithRetry(address string, timeout time.Duration, retry bool) (net.Conn, error)
- func (l *StreamLayer) Handoff(conn net.Conn)
- func (l *StreamLayer) ProxyRequest(addr string, msg *Request, from io.ReadWriter) error
- func (l *StreamLayer) RPC(addr string, msg *Request) (*Response, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClosedConn is the error returned when the underlying listener has been closed ErrClosedConn = errors.New("use of closed network connection") )
Functions ¶
This section is empty.
Types ¶
type Server ¶
Server handles routing from an an incoming conneciton to a specified backend. These backends are determined based on the 1st byte read from the incoming connection
type StreamLayer ¶
type StreamLayer struct {
// contains filtered or unexported fields
}
StreamLayer is used for handling rpc requests between nodes (be it raft, or other custom RPC) When a request comes into an RPC Server, the Server will route it to the appropriate StreamLayer StreamLayer implements raft.StreamLayer and net.Listener
func NewStreamLayer ¶
func NewStreamLayer(addr net.Addr, rpcType byte, dialer DialerFn) *StreamLayer
NewStreamLayer creates a new StreamLayer `addr` is used so this can implement the net.Listener interface `rpcType` is the type of Message this StreamLayer will handle
func (*StreamLayer) Accept ¶
func (l *StreamLayer) Accept() (net.Conn, error)
Accept waits for and returns the next connection
func (*StreamLayer) Addr ¶
func (l *StreamLayer) Addr() net.Addr
Addr returns the address the stremLayer is listening on This is used to satisfy the net.Listener interface
func (*StreamLayer) DialWithRetry ¶
func (l *StreamLayer) DialWithRetry(address string, timeout time.Duration, retry bool) (net.Conn, error)
DialWithRetry is like `Dial` but uses a retry mechanism
func (*StreamLayer) Handoff ¶
func (l *StreamLayer) Handoff(conn net.Conn)
Handoff is used by the RPC server hand-off a conn to this StreamLayer
func (*StreamLayer) ProxyRequest ¶
func (l *StreamLayer) ProxyRequest(addr string, msg *Request, from io.ReadWriter) error
ProxyRequest is a helper function to proxy an rpc request to another node