cluster

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoLeader  = errors.New("no leader")
	ErrNotLeader = errors.New("not a leader")
)

Functions

This section is empty.

Types

type Cluster

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

func NewCluster

func NewCluster(ctx context.Context, cfg config.EtcdConfig) (*Cluster, error)

func (*Cluster) Close

func (c *Cluster) Close() error

func (*Cluster) Discovery

func (c *Cluster) Discovery(ctx context.Context, svcPath string) ([]string, error)

func (*Cluster) NewElection

func (c *Cluster) NewElection(ctx context.Context, prefix string) *Election

func (*Cluster) Register

func (c *Cluster) Register(ctx context.Context, svcPath string, id string) error

type ClusterRole

type ClusterRole int
const (
	RoleCandidate ClusterRole = iota
	RoleFollower  ClusterRole = iota
	RoleLeader    ClusterRole = iota
)

type Election

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

func (*Election) Campaign

func (e *Election) Campaign(ctx context.Context, val string) (ClusterRole, error)

func (*Election) Leader

func (e *Election) Leader(ctx context.Context) (*RoleInfo, error)

func (*Election) Renew

func (el *Election) Renew(ctx context.Context) error

func (*Election) Resign

func (e *Election) Resign(ctx context.Context) error

type RoleInfo

type RoleInfo struct {
	Address string
	Role    ClusterRole
}

Jump to

Keyboard shortcuts

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