cluster

package
v0.6.9 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLeaseTTL etcd lease time-to-live in seconds
	DefaultLeaseTTL int64 = 10
	ClusterAlive    State = iota
	ClusterLeaving
	ClusterLeft
	ClusterJoining
)

Variables

This section is empty.

Functions

func GetID

func GetID() string

GetID makes cluster id be available across modules.

Types

type Cluster

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

Cluster manages a set of member and the consistent hash ring as well.

func New

func New(id string, bindAddr string, l log.Logger, e *common.Etcd) (*Cluster, error)

New creates a new cluster manager instance.

func (*Cluster) LocalIsWorker

func (c *Cluster) LocalIsWorker(key string) (string, string, bool)

LocalIsWorker checks if the local node is the worker which has responsibility for the given string key.

func (*Cluster) LocalMember

func (c *Cluster) LocalMember() model.Member

LocalMember returns the local node member.

func (*Cluster) Run

func (c *Cluster) Run(rc chan struct{})

Run watches the cluster state's changes and does its job

func (*Cluster) Stop

func (c *Cluster) Stop()

Stop stops the member as well as the watch process

type State

type State int

State is the state of the Cluster instance

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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