Documentation
¶
Overview ¶
Package tcp provides TCP based transports.
Index ¶
- func NewBootstrapTransport(opts BootstrapTransportOptions) transport.BootstrapTransport
- func NewJoinRoundTripper(opts RoundTripOptions) transport.JoinRoundTripper
- func NewRaftTransport(leaderDialer transport.LeaderDialer, opts RaftTransportOptions) (transport.RaftTransport, error)
- func NewRoundTripper[REQ, RESP any](opts RoundTripOptions, method string) transport.RoundTripper[REQ, RESP]
- type BootstrapPeer
- type BootstrapTransportOptions
- type RaftTransport
- type RaftTransportOptions
- type RoundTripOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBootstrapTransport ¶
func NewBootstrapTransport(opts BootstrapTransportOptions) transport.BootstrapTransport
NewBootstrapTransport creates a new TCP transport listening on the given address. It uses a temporary in-memory raft cluster to perform leader election and then disposes of it.
func NewJoinRoundTripper ¶
func NewJoinRoundTripper(opts RoundTripOptions) transport.JoinRoundTripper
NewJoinRoundTripper creates a new gRPC round tripper for issuing a Join Request.
func NewRaftTransport ¶
func NewRaftTransport(leaderDialer transport.LeaderDialer, opts RaftTransportOptions) (transport.RaftTransport, error)
NewRaftTransport creates a new TCP transport listening on the given address.
func NewRoundTripper ¶
func NewRoundTripper[REQ, RESP any](opts RoundTripOptions, method string) transport.RoundTripper[REQ, RESP]
NewRoundTripper creates a new gRPC round tripper for the given method.
Types ¶
type BootstrapPeer ¶
type BootstrapPeer struct {
// NodeID is the peer id.
NodeID string
// AdvertiseAddr is the peer advertise address for leader election.
AdvertiseAddr string
// DialAddr is the peer dial address for after leader election.
DialAddr string
}
BootstrapPeer is a TCP bootstrap peer.
type BootstrapTransportOptions ¶
type BootstrapTransportOptions struct {
// NodeID is the node id of the current node.
NodeID string
// Addr is the address to listen on.
Addr string
// Peers is a map of peer ids to addresses to dial.
Peers map[string]BootstrapPeer
// Advertise is the address to advertise.
Advertise string
// MaxPool is the maximum number of connections to pool.
MaxPool int
// Timeout is the timeout for dialing a connection.
Timeout time.Duration
// ElectionTimeout is the election timeout.
ElectionTimeout time.Duration
// Credentials are the credentials to use when dialing peers.
Credentials []grpc.DialOption
}
BootstrapTransportOptions are options for the TCP transport.
type RaftTransport ¶
type RaftTransport struct {
*raft.NetworkTransport
transport.LeaderDialer
// contains filtered or unexported fields
}
RaftTransport is a transport that uses raw TCP.
func (*RaftTransport) AddrPort ¶
func (t *RaftTransport) AddrPort() netip.AddrPort
type RaftTransportOptions ¶
type RaftTransportOptions 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
}
RaftTransportOptions are options for the TCP transport.
type RoundTripOptions ¶
type RoundTripOptions struct {
// Addrs is a list of addresses to try to join. The list will be iterated on
// until a successful join occurs.
Addrs []string
// Credentials are the gRPC DialOptions to use for the gRPC connection.
Credentials []grpc.DialOption
// AddressTimeout is the timeout for dialing each address. If not set
// any timeout on the context will be used.
AddressTimeout time.Duration
}
RoundTripOptions are options for a gRPC round tripper.