Documentation ¶
Overview ¶
Package transport provides grpc transport layer for raft. All methods are non-blocking.
Index ¶
- Variables
- type Config
- type Raft
- type 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) 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 ¶
This section is empty.
Variables ¶
var ErrIsNotFound = errors.New("peer not found")
ErrIsNotFound indicates that peer was never added to transport.
Functions ¶
This section is empty.
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 (*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) 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) 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.