Documentation ¶
Index ¶
- Constants
- type BeskarMeta
- type Config
- type InstanceType
- type Member
- func (member *Member) LocalNode() *memberlist.Node
- func (member *Member) LocalState() ([]byte, error)
- func (member *Member) MarkAsReady(timeout time.Duration) error
- func (member *Member) Nodes() []*memberlist.Node
- func (member *Member) RemoteState() ([]byte, error)
- func (member *Member) Send(node *memberlist.Node, msg []byte) error
- func (member *Member) Shutdown() error
- func (member *Member) Watch() <-chan MemberEvent
- type MemberEvent
- type MemberOption
Constants ¶
const ( // DefaultLeaveTimeout is the time to wait during while leaving cluster DefaultLeaveTimeout = 5 * time.Second // DefaultReadyTimeout is the time to wait during ready status update DefaultReadyTimeout = 2 * time.Second )
const ( // NodeJoin represents an event about a node join. NodeJoin memberlist.NodeEventType = iota << 1 // NodeLeave represents an event about a node leave. NodeLeave // NodeUpdate represents an event about a node update. NodeUpdate // NodeMessage represents an event about a user message. NodeMessage // NodeError represents an event about a node error. NodeError )
const (
GossipLabelKey = "go.ciq.dev/beskar-gossip"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BeskarMeta ¶
type BeskarMeta struct { // Beskar or plugin instance. InstanceType InstanceType // Ready state Ready bool // Groupcache service port for beskar instances or HTTP service for plugin instances. ServicePort uint16 // Registry service port for beskar instances. RegistryPort uint16 // Hostname, provided as part of metadata as gossip is randomizing node name, // for beskar instances it will return the configured hostname, for plugins it returns // the node hostname Hostname string }
func NewBeskarMeta ¶
func NewBeskarMeta() *BeskarMeta
func (*BeskarMeta) Decode ¶
func (bm *BeskarMeta) Decode(buf []byte) error
Decode decodes gob format meta data and returns a NodeMeta corresponding structure.
func (*BeskarMeta) Encode ¶
func (bm *BeskarMeta) Encode() ([]byte, error)
type InstanceType ¶ added in v0.0.3
type InstanceType uint8
const ( BeskarInstance InstanceType = iota + 1 PluginInstance )
type Member ¶
type Member struct {
// contains filtered or unexported fields
}
Member represents a member part of a gossip cluster.
func NewMember ¶
func NewMember(name string, peers []string, memberOpt ...MemberOption) (*Member, error)
NewMember creates and/or participates to a gossip cluster.
func Start ¶
func Start(gossipConfig Config, meta *BeskarMeta, client kubernetes.Interface, timeout time.Duration) (*Member, error)
func (*Member) LocalNode ¶
func (member *Member) LocalNode() *memberlist.Node
LocalNode returns the current node information.
func (*Member) LocalState ¶
LocalState returns the state of the node if any.
func (*Member) MarkAsReady ¶ added in v0.0.3
MarkAsReady updates node metadata ready status and advertise nodes about change.
func (*Member) Nodes ¶
func (member *Member) Nodes() []*memberlist.Node
Nodes returns all nodes participating to the cluster.
func (*Member) RemoteState ¶
PeerState returns the state of the peer used to join the cluster if any.
func (*Member) Send ¶
func (member *Member) Send(node *memberlist.Node, msg []byte) error
Send senda message to a particular node.
func (*Member) Watch ¶
func (member *Member) Watch() <-chan MemberEvent
Watch returns an event channel to react to various notifications coming from gossip protocol (join, leave, update ...).
type MemberEvent ¶
type MemberEvent struct { EventType memberlist.NodeEventType Arg interface{} }
MemberEvent
type MemberOption ¶
type MemberOption func(*memberlist.Config) error
MemberOption defines a member configuration function.
func WithBindAddress ¶
func WithBindAddress(addr string) MemberOption
WithBindAddress sets the bind address to listen on.
func WithLocalState ¶
func WithLocalState(state []byte) MemberOption
func WithNodeMeta ¶
func WithNodeMeta(meta []byte) MemberOption
WithNodeMeta sets meta data associated to a node.
func WithSecretKey ¶
func WithSecretKey(key []byte) MemberOption
WithSecretKey sets the secret key used to encrypt/decrypt communications.