Documentation ¶
Overview ¶
Package transport defines the interfaces needed for various mesh operations.
Index ¶
- Variables
- type BootstrapTransport
- type BootstrapTransportFunc
- type JoinRoundTripper
- type JoinRoundTripperFunc
- type JoinServer
- type JoinServerFunc
- type LeaderDialer
- type LeaderDialerFunc
- type NodeDialer
- type NodeDialerFunc
- type RaftTransport
- type RoundTripper
- type RoundTripperFunc
- type UnaryServer
- type UnaryServerFunc
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyBootstrapped = raft.ErrCantBootstrap
ErrAlreadyBootstrapped is returned when a node believes the cluster to be already bootstrapped.
Functions ¶
This section is empty.
Types ¶
type BootstrapTransport ¶ added in v0.3.1
type BootstrapTransport interface { // LeaderElect should perform an initial leader election. It returns // true is this node was elected leader, or otherwise a JoinRoundTripper // for contacting the elected leader. If one or more nodes believe // the cluster to be already bootstrapped, then ErrAlreadyBootstrapped // should be returned with an optional JoinRoundTripper to nodes who are // already bootstrapped. LeaderElect(ctx context.Context) (isLeader bool, rt JoinRoundTripper, err error) }
BootstrapTransport is the interface for dialing other peers to bootstrap a new mesh.
func NewNullBootstrapTransport ¶ added in v0.3.1
func NewNullBootstrapTransport() BootstrapTransport
NewNullBootstrapTransport returns a BootstrapTransport that always returns true for LeaderElect and nil for JoinRoundTripper. This is useful for testing and when no bootstrap transport is needed.
type BootstrapTransportFunc ¶ added in v0.3.1
type BootstrapTransportFunc func(ctx context.Context) (isLeader bool, rt JoinRoundTripper, err error)
BootstrapTransportFunc is a function that implements BootstrapTransport.
func (BootstrapTransportFunc) LeaderElect ¶ added in v0.3.1
func (f BootstrapTransportFunc) LeaderElect(ctx context.Context) (isLeader bool, rt JoinRoundTripper, err error)
LeaderElect implements BootstrapTransport.
type JoinRoundTripper ¶ added in v0.3.1
type JoinRoundTripper = RoundTripper[v1.JoinRequest, v1.JoinResponse]
JoinRoundTripper is the interface for joining a cluster.
type JoinRoundTripperFunc ¶ added in v0.3.1
type JoinRoundTripperFunc = RoundTripperFunc[v1.JoinRequest, v1.JoinResponse]
JoinRoundTripperFunc is a function that implements JoinRoundTripper.
type JoinServer ¶ added in v0.3.1
type JoinServer = UnaryServer[v1.JoinRequest, v1.JoinResponse]
JoinServer is the interface for handling requests to join a cluster.
type JoinServerFunc ¶ added in v0.3.1
type JoinServerFunc = UnaryServerFunc[v1.JoinRequest, v1.JoinResponse]
JoinServerFunc is a function that implements JoinServer.
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.
type RoundTripper ¶ added in v0.3.1
type RoundTripper[REQ, RESP any] interface { RoundTrip(ctx context.Context, req *REQ) (*RESP, error) }
RoundTripper is a generic interface for executing a request and returning a response.
type RoundTripperFunc ¶ added in v0.3.1
RoundTripperFunc is a function that implements RoundTripper.
type UnaryServer ¶ added in v0.3.1
type UnaryServer[REQ, RESP any] interface { // Serve is executed when a unary request is received. Serve(ctx context.Context, req *REQ) (*RESP, error) }
UnaryServer is the interface for handling unary requests.
type UnaryServerFunc ¶ added in v0.3.1
UnaryServerFunc is a function that implements UnaryServer.