tcp

package
v0.17.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package tcp provides TCP based transports.

Index

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 NewGRPCTransport added in v0.15.0

func NewGRPCTransport(opts TransportOptions) transport.RPCTransport

NewGRPCTransport creates a new gRPC transport using the native gRPC dialer.

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
	// DataDirectory is the directory to use for the bootstrap transport.
	// This is where the results of an initial bootstrap are stored. If not provided,
	// an in-memory directory is used.
	DataDirectory string
}

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.

type TransportOptions added in v0.15.0

type TransportOptions struct {
	// MaxRetries is the maximum number of retries for a request.
	MaxRetries int
	// Credentials are the gRPC DialOptions to use for the gRPC connection.
	Credentials []grpc.DialOption
}

TransportOptions are options for a TCP RPC transport.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL