gossip

package
v3.0.0-...-a9a26d0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PingVersion is an internal version for the ping message, above the normal
	// versioning we get from the protocol version. This enables small updates
	// to the ping message without a full protocol bump.
	PingVersion = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GossipConfig

type GossipConfig struct {
	// GossipProbeInterval define the probe interval used by the gossip
	// service in tests.
	// GossipProbeInterval time.Duration `json:"gossipProbeInterval"`
	// BindAddress is the address for the gossip service to bind to and listen on.
	// Both UDP and TCP ports are used by the gossip service. The local gossip
	// service should be able to receive gossip service related messages by
	// binding to and listening on this address. BindAddress is usually in the
	// format of IP:Port, Hostname:Port or DNS Name:Port.
	BindAddress string `json:"-"`
	BindPort    uint16 `json:"bindPort"`

	// AdvertiseAddress is the address to advertise to other NodeHost instances
	// used for NAT traversal. Gossip services running on remote NodeHost
	// instances will use AdvertiseAddress to exchange gossip service related
	// messages. AdvertiseAddress is in the format of IP:Port.
	// AdvertiseAddress string
	// Seed is a list of AdvertiseAddress of remote NodeHost instances. Local
	// NodeHost instance will try to contact all of them to bootstrap the gossip
	// service. At least one reachable NodeHost instance is required to
	// successfully bootstrap the gossip service. Each seed address is in the
	// format of IP:Port, Hostname:Port or DNS Name:Port.
	//
	// It is ok to include seed addresses that are temporarily unreachable, e.g.
	// when launching the first NodeHost instance in your deployment, you can
	// include AdvertiseAddresses from other NodeHost instances that you plan to
	// launch shortly afterwards.
	Seeds []string `json:"seeds"`
	// contains filtered or unexported fields
}

func (*GossipConfig) IsEmpty

func (g *GossipConfig) IsEmpty() bool

IsEmpty returns a boolean flag indicating whether the GossipConfig instance is empty.

func (*GossipConfig) SetShardCallback

func (g *GossipConfig) SetShardCallback(fn ShardCallback)

func (*GossipConfig) Validate

func (g *GossipConfig) Validate() error

Validate validates the GossipConfig instance.

type GossipManager

type GossipManager struct {
	// contains filtered or unexported fields
}

func NewGossipManager

func NewGossipManager(config GossipConfig, opts GossipOptions) (*GossipManager, error)

func (*GossipManager) Close

func (g *GossipManager) Close() error

func (*GossipManager) GetAliveInstances

func (g *GossipManager) GetAliveInstances() map[string]bool

func (*GossipManager) GetCachedCoordinate

func (g *GossipManager) GetCachedCoordinate(name string) (coord *coordinate.Coordinate, ok bool)

func (*GossipManager) GetCoordinate

func (g *GossipManager) GetCoordinate() (*coordinate.Coordinate, error)

GetCoordinate returns the network coordinate of the local node.

func (*GossipManager) GetMembershipMessage

func (g *GossipManager) GetMembershipMessage(shardId uint64) *MemberInfo

func (*GossipManager) GetMembershipMessages

func (g *GossipManager) GetMembershipMessages() map[uint64]*MemberInfo

func (*GossipManager) GetShardMessage

func (g *GossipManager) GetShardMessage() *RaftShardMessage

func (*GossipManager) GetserverInstances

func (g *GossipManager) GetserverInstances() map[string]bool

func (*GossipManager) SetNodeMeta

func (g *GossipManager) SetNodeMeta(meta Meta) error

func (*GossipManager) UpdateMembershipMessage

func (g *GossipManager) UpdateMembershipMessage(membership *RaftMembershipMessage)

func (*GossipManager) UpdateShardMessage

func (g *GossipManager) UpdateShardMessage(shard *RaftShardMessage)

type GossipOptions

type GossipOptions struct {
	// gossip name
	Name string

	// shard moveTo grpc addr
	MoveToGrpcAddr string

	// server grpc addr
	ServerGrpcAddr string

	GossipNodes        int
	LogDir             string
	LogLevel           zapcore.Level
	DisableCoordinates bool
}

type MemberInfo

type MemberInfo struct {
	ShardId        uint64
	ConfigChangeId uint64
	Replicas       map[uint64]string
	Observers      map[uint64]string
	LeaderId       uint64
	LeaderValid    bool
}

func (*MemberInfo) String

func (mi *MemberInfo) String() string

type Meta

type Meta struct {
	MoveToGrpcAddr string
	ServerGrpcAddr string
}

type PushPullMessage

type PushPullMessage struct {
	Shard      *RaftShardMessage
	Membership *RaftMembershipMessage
}

func (*PushPullMessage) String

func (pp *PushPullMessage) String() string

type RaftMembershipMessage

type RaftMembershipMessage struct {
	// key: shardId
	MemberInfos map[uint64]*MemberInfo
}

func (*RaftMembershipMessage) String

func (rm *RaftMembershipMessage) String() string

type RaftShardMessage

type RaftShardMessage struct {
	Revision int64 `json:"revision"`

	// 机器ID对应的MoveTo的GRPC地址
	// key: 当raft以nodehostid=true的方式起的时候是机器ID,以固定地址方式起是raftAddr
	Targets map[string]TargetShardId `json:"targets"`

	// 每个raft shard对应的机器ID|raftAddr
	Shards map[uint64][]string `json:"shards"`

	// 每个raft shard的initial members
	// key: shardId, key: replicaId, val: raftAddr或nodeHostID
	InitialMembers map[uint64]map[uint64]string `json:"initial_members"`
	Join           map[uint64]map[uint64]bool   `json:"join"`
}

func (*RaftShardMessage) String

func (rm *RaftShardMessage) String() string

type ShardCallback

type ShardCallback func(shard *RaftShardMessage) error

type TargetShardId

type TargetShardId struct {
	GrpcAddr string   `json:"grpcAddr"`
	ShardIds []uint64 `json:"shardIds"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL