Documentation
¶
Index ¶
- func OversizedMessage(b []byte, size int) bool
- type Channel
- type NoopSpreader
- type Option
- type Options
- type Payload
- type Peer
- func (p *Peer) AddShard(sd Shard) (Spreader, error)
- func (p *Peer) Address() string
- func (p *Peer) Join(ctx context.Context) error
- func (p *Peer) MemberCount() int
- func (p *Peer) OthersNodes() []*memberlist.Node
- func (p *Peer) ReliableMsgHandle(ctx context.Context) error
- func (p *Peer) SendReliable(b []byte)
- func (p *Peer) Start(ctx context.Context) error
- func (p *Peer) Stop(ctx context.Context) error
- type Shard
- type Spreader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OversizedMessage ¶
OversizedMessage indicates whether the byte payload should be sent via TCP.
Types ¶
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
Channel is a channel for communication between shard holding nodes.
func NewChannel ¶
NewChannel creates a new channel for the given shard.
type NoopSpreader ¶
type NoopSpreader struct{}
func (*NoopSpreader) Broadcast ¶
func (n *NoopSpreader) Broadcast([]byte) error
type Option ¶
type Option func(*Options)
func WithConfiguration ¶
func WithConfiguration(cnf *conf.Configuration) Option
type Options ¶
type Options struct {
// ExistsPeers is the list of known peers to join
ExistsPeers []string `yaml:"existsPeers" json:"existsPeers"`
JoinTTL time.Duration `yaml:"joinTTL" json:"joinTTL"`
JoinRetry int `yaml:"joinRetry" json:"joinRetry"`
// MembersConfig is the memberlist.Config for the peer.
// note that: bind address should be ip address, not hostname.
MembersConfig *memberlist.Config `yaml:"membersConfig" json:"membersConfig"`
Event memberlist.EventDelegate `yaml:"-" json:"-"`
Delegate memberlist.Delegate `yaml:"-" json:"-"`
// contains filtered or unexported fields
}
type Peer ¶
type Peer struct {
Options
// contains filtered or unexported fields
}
Peer is a memberlist Node wrapper
func (*Peer) MemberCount ¶
func (*Peer) OthersNodes ¶
func (p *Peer) OthersNodes() []*memberlist.Node
func (*Peer) SendReliable ¶
SendReliable uses sending large message (see OversizedMessage) to other nodes. It calls memberlist.SendReliable.
type Shard ¶
type Shard interface {
// Name returns the name of the shard, which is used to identify the shard.
Name() string
// MarshalBinary marshals the shard data into a binary to sync other nodes.
MarshalBinary() ([]byte, error)
// Merge data from remote node MarshalBinary result. The Shard should be able to dedupe the data.
Merge(b []byte) error
}
Shard is some specified distributed data handler.
Click to show internal directories.
Click to hide internal directories.