Documentation ¶
Overview ¶
Package transport provides a simple interface for sending and receiving raft messages between nodes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LeaderDialer ¶
type LeaderDialer interface { // DialLeader opens a gRPC connection to the current leader. DialLeader(ctx context.Context) (*grpc.ClientConn, error) }
LeaderDialer is the interface for dialing the current leader.
type LeaderDialerFunc ¶
type LeaderDialerFunc func(ctx context.Context) (*grpc.ClientConn, error)
LeaderDialerFunc is a function that implements LeaderDialer.
func (LeaderDialerFunc) DialLeader ¶
func (f LeaderDialerFunc) DialLeader(ctx context.Context) (*grpc.ClientConn, error)
DialLeader implements LeaderDialer.
type NodeDialer ¶
NodeDialer is an interface for dialing an arbitrary node. The node ID is optional and if empty, implementations can choose the node to dial.
type NodeDialerFunc ¶
NodeDialerFunc is the function signature for dialing an arbitrary node. It is supplied by the mesh during startup. It can be used as an alternative to the NodeDialer interface.
func (NodeDialerFunc) Dial ¶
func (f NodeDialerFunc) Dial(ctx context.Context, id string) (*grpc.ClientConn, error)
Dial implements NodeDialer.
type RaftTransport ¶
type RaftTransport interface { raft.Transport LeaderDialer // AddrPort returns the address and port the transport is listening on. AddrPort() netip.AddrPort // Close closes the transport. Close() error }
RaftTransport defines the methods needed for raft consensus to function in a webmesh cluster.
func NewRaftTCPTransport ¶
func NewRaftTCPTransport(leaderDialer LeaderDialer, opts TCPTransportOptions) (RaftTransport, error)
NewRaftTCPTransport creates a new TCP transport listening on the given address.
type TCPTransport ¶
type TCPTransport struct { *raft.NetworkTransport LeaderDialer // contains filtered or unexported fields }
TCPTransport is a transport that uses raw TCP.
func (*TCPTransport) AddrPort ¶
func (t *TCPTransport) AddrPort() netip.AddrPort
type TCPTransportOptions ¶
type TCPTransportOptions struct { // Addr is the address to listen on. Addr string // MaxPool is the maximum number of connections to pool. MaxPool int // Timeout is the timeout for dialing a connection. Timeout time.Duration }
TCPTransportOptions are options for the TCP transport.