package transport
import "github.com/moby/swarmkit/v2/manager/state/raft/transport"
Package transport provides grpc transport layer for raft. All methods are non-blocking.
Index ¶
- Constants
- Variables
- type Config
- type Raft
- type Transport
- func New(cfg *Config) *Transport
- func (t *Transport) Active(id uint64) bool
- func (t *Transport) AddPeer(id uint64, addr string) error
- func (t *Transport) HealthCheck(ctx context.Context, id uint64) error
- func (t *Transport) LongestActive() (uint64, error)
- func (t *Transport) PeerAddr(id uint64) (string, error)
- func (t *Transport) PeerConn(id uint64) (*grpc.ClientConn, error)
- func (t *Transport) RemovePeer(id uint64) error
- func (t *Transport) Send(m raftpb.Message) error
- func (t *Transport) Stop()
- func (t *Transport) UpdatePeer(id uint64, addr string) error
- func (t *Transport) UpdatePeerAddr(id uint64, addr string) error
Constants ¶
const ( // GRPCMaxMsgSize is the max allowed gRPC message size for raft messages. GRPCMaxMsgSize = 4 << 20 )
Variables ¶
ErrIsNotFound indicates that peer was never added to transport.
Types ¶
type Config ¶
type Config struct {
HeartbeatInterval time.Duration
SendTimeout time.Duration
Credentials credentials.TransportCredentials
RaftID string
Raft
}
Config for Transport
type Raft ¶
type Raft interface {
ReportUnreachable(id uint64)
ReportSnapshot(id uint64, status raft.SnapshotStatus)
IsIDRemoved(id uint64) bool
UpdateNode(id uint64, addr string)
NodeRemoved()
}
Raft is interface which represents Raft API for transport package.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is structure which manages remote raft peers and sends messages to them.
func New ¶
New returns new Transport with specified Config.
func (*Transport) Active ¶
Active returns true if node was recently active and false otherwise.
func (*Transport) AddPeer ¶
AddPeer adds new peer with id and address addr to Transport. If there is already peer with such id in Transport it will return error if address is different (UpdatePeer should be used) or nil otherwise.
func (*Transport) HealthCheck ¶
HealthCheck checks health of particular peer.
func (*Transport) LongestActive ¶
LongestActive returns the ID of the peer that has been active for the longest length of time.
func (*Transport) PeerAddr ¶
PeerAddr returns address of peer with id.
func (*Transport) PeerConn ¶
func (t *Transport) PeerConn(id uint64) (*grpc.ClientConn, error)
PeerConn returns raw grpc connection to peer.
func (*Transport) RemovePeer ¶
RemovePeer removes peer from Transport and wait for it to stop.
func (*Transport) Send ¶
Send sends raft message to remote peers.
func (*Transport) Stop ¶
func (t *Transport) Stop()
Stop stops transport and waits until it finished
func (*Transport) UpdatePeer ¶
UpdatePeer updates peer with new address. It replaces connection immediately.
func (*Transport) UpdatePeerAddr ¶
UpdatePeerAddr updates peer with new address, but delays connection creation. New address won't be used until first failure on old address.
Source Files ¶
- Version
- v2.1.1 (latest)
- Published
- Oct 7, 2025
- Platform
- linux/amd64
- Imports
- 17 packages
- Last checked
- 4 months ago –
Tools for package owners.