-
Notifications
You must be signed in to change notification settings - Fork 0
/
transport.go
38 lines (30 loc) · 1.18 KB
/
transport.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package raft
import (
"context"
"io"
"github.com/sumimakito/raft/pb"
)
type Transport interface {
// Endpoint returns the endpoint used by current Transport instance
Endpoint() string
AppendEntries(ctx context.Context, peer *pb.Peer, request *pb.AppendEntriesRequest) (*pb.AppendEntriesResponse, error)
RequestVote(ctx context.Context, peer *pb.Peer, request *pb.RequestVoteRequest) (*pb.RequestVoteResponse, error)
InstallSnapshot(ctx context.Context, peer *pb.Peer, requestMeta *pb.InstallSnapshotRequestMeta, reader io.Reader) (*pb.InstallSnapshotResponse, error)
ApplyLog(ctx context.Context, peer *pb.Peer, request *pb.ApplyLogRequest) (*pb.ApplyLogResponse, error)
RPC() <-chan *RPC
}
// TransportConnecter is an optional interface for those implementations
// that allow explicit connect and disconnect operations on a per peer basis.
type TransportConnecter interface {
Connect(peer *pb.Peer) error
Disconnect(peer *pb.Peer)
DisconnectAll()
}
type TransportServer interface {
Serve() error
}
// TransportCloser is an optional interface for those implementations
// that allow explicit close operation on its underlying connections.
type TransportCloser interface {
Close() error
}