Documentation ¶
Index ¶
- Constants
- Variables
- type Chunk
- type Connection
- type ContainerResolver
- type MessageHandler
- type SnapshotChunkHandler
- type SnapshotConnection
- type SnapshotStatusHandler
- type TCP
- type TCPConnection
- type TCPSnapshotConnection
- type Trans
- type TransImpl
- type Transport
- func (t *Transport) Close() error
- func (t *Transport) Name() string
- func (t *Transport) Send(m meta.RaftMessage) bool
- func (t *Transport) SendSnapshot(m meta.RaftMessage) bool
- func (t *Transport) SendingSnapshotCount() uint64
- func (t *Transport) SetFilter(f func(meta.RaftMessage) bool)
- func (t *Transport) Start() error
- type UnreachableHandler
Constants ¶
const (
SnapshotChunkSize = 1024 * 1024 * 4
)
const (
// TCPTransportName is the name of the tcp transport module.
TCPTransportName = "go-tcp-transport"
)
Variables ¶
var ( // ErrBadMessage is the error returned to indicate the incoming message is // corrupted. ErrBadMessage = errors.New("invalid message") )
var ( // ErrSnapshotOutOfDate is returned when the snapshot being received is // considered as out of date. ErrSnapshotOutOfDate = errors.New("snapshot is out of date") )
var ( // ErrStopped is the error returned to indicate that the connection has // already been stopped. ErrStopped = errors.New("connection stopped") )
Functions ¶
This section is empty.
Types ¶
type Chunk ¶ added in v0.2.0
type Chunk struct {
// contains filtered or unexported fields
}
Chunk managed on the receiving side
func NewChunk ¶ added in v0.2.0
func NewChunk(logger *zap.Logger, onReceive func(meta.RaftMessageBatch), dir snapshot.SnapshotDirFunc, fs vfs.FS) *Chunk
NewChunk creates and returns a new snapshot chunks instance.
type Connection ¶ added in v0.2.0
type Connection interface { // Close closes the Connection instance. Close() // SendMessageBatch sends the specified message batch to the target. It is // recommended to deliver the message batch to the target in order to enjoy // best possible performance, but out of order delivery is allowed at the // cost of reduced performance. SendMessageBatch(batch meta.RaftMessageBatch) error }
Connection is the interface used by the transport module for sending Raft messages. Each Connection works for a specified target store instance, it is possible for a target to have multiple concurrent Connection instances in use.
type ContainerResolver ¶
type MessageHandler ¶
type MessageHandler func(meta.RaftMessageBatch)
type SnapshotChunkHandler ¶ added in v0.2.0
type SnapshotChunkHandler func(meta.SnapshotChunk) bool
type SnapshotConnection ¶ added in v0.2.0
type SnapshotConnection interface { // Close closes the SnapshotConnection instance. Close() // SendChunk sends the snapshot chunk to the target. It is // recommended to have the snapshot chunk delivered in order for the best // performance, but out of order delivery is allowed at the cost of reduced // performance. SendChunk(chunk meta.SnapshotChunk) error }
SnapshotConnection is the interface used by the transport module for sending snapshot chunks. Each SnapshotConnection works for a specified target store instance.
type SnapshotStatusHandler ¶ added in v0.2.0
type TCP ¶ added in v0.2.0
type TCP struct {
// contains filtered or unexported fields
}
TCP is a TCP based transport module for exchanging raft messages and snapshots between NodeHost instances.
func (*TCP) GetConnection ¶ added in v0.2.0
GetConnection returns a new raftio.IConnection for sending raft messages.
func (*TCP) GetSnapshotConnection ¶ added in v0.2.0
GetSnapshotConnection returns a new raftio.IConnection for sending raft snapshots.
type TCPConnection ¶ added in v0.2.0
type TCPConnection struct {
// contains filtered or unexported fields
}
TCPConnection is the connection used for sending raft messages to remote nodes.
func NewTCPConnection ¶ added in v0.2.0
NewTCPConnection creates and returns a new TCPConnection instance.
func (*TCPConnection) Close ¶ added in v0.2.0
func (c *TCPConnection) Close()
Close closes the TCPConnection instance.
func (*TCPConnection) SendMessageBatch ¶ added in v0.2.0
func (c *TCPConnection) SendMessageBatch(batch meta.RaftMessageBatch) error
SendMessageBatch sends a raft message batch to remote node.
type TCPSnapshotConnection ¶ added in v0.2.0
type TCPSnapshotConnection struct {
// contains filtered or unexported fields
}
TCPSnapshotConnection is the connection for sending raft snapshot chunks to remote nodes.
func NewTCPSnapshotConnection ¶ added in v0.2.0
func NewTCPSnapshotConnection(logger *zap.Logger, conn net.Conn, encrypted bool) *TCPSnapshotConnection
NewTCPSnapshotConnection creates and returns a new snapshot connection.
func (*TCPSnapshotConnection) Close ¶ added in v0.2.0
func (c *TCPSnapshotConnection) Close()
Close closes the snapshot connection.
func (*TCPSnapshotConnection) SendChunk ¶ added in v0.2.0
func (c *TCPSnapshotConnection) SendChunk(chunk meta.SnapshotChunk) error
SendChunk sends the specified snapshot chunk to remote node.
type Trans ¶ added in v0.2.0
type Trans interface { Send(meta.RaftMessage) bool SendSnapshot(meta.RaftMessage) bool SetFilter(func(meta.RaftMessage) bool) SendingSnapshotCount() uint64 Start() error Close() error }
type TransImpl ¶ added in v0.2.0
type TransImpl interface { // Name returns the type name of the TransImpl instance. Name() string // Start launches the transport module and make it ready to start sending and // receiving Raft messages. If necessary, TransImpl may take this opportunity // to start listening for incoming data. Start() error // Close closes the transport module. Close() error // GetConnection returns an Connection instance used for sending messages // to the specified target store instance. GetConnection(ctx context.Context, target string) (Connection, error) // GetSnapshotConnection returns an Connection instance used for transporting // snapshots to the specified store instance. GetSnapshotConnection(ctx context.Context, target string) (SnapshotConnection, error) }
TransImpl is the interface to be implemented by a customized transport module. A transport module is responsible for exchanging Raft messages, snapshots and other metadata between store instances.
func NewTCPTransport ¶ added in v0.2.0
func NewTCPTransport(logger *zap.Logger, addr string, requestHandler MessageHandler, chunkHandler SnapshotChunkHandler) TransImpl
NewTCPTransport creates and returns a new TCP transport module.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is the transport layer for delivering raft messages and snapshots.
func NewTransport ¶ added in v0.2.0
func NewTransport(logger *zap.Logger, addr string, storeID uint64, handler MessageHandler, unreachable UnreachableHandler, snapshotStatus SnapshotStatusHandler, dir snapshot.SnapshotDirFunc, resolver ContainerResolver, fs vfs.FS) *Transport
func (*Transport) SendSnapshot ¶ added in v0.2.0
func (t *Transport) SendSnapshot(m meta.RaftMessage) bool
SendSnapshot asynchronously sends raft snapshot message to its target.