cluster

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: Apache-2.0 Imports: 14 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 interface {
	Close() error
	NewElection(ctx context.Context, electionKey string, id string) Election
	Register(ctx context.Context, serviceName string, instanceID string) error
	Discover(ctx context.Context, serviceName string) ([]string, error)
}

func NewEtcdCluster added in v0.1.8

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

func NewRedisCluster added in v0.1.8

func NewRedisCluster(ctx context.Context, cfg config.RedisConfig, ttl int) (Cluster, error)

type ClusterRole

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

type Election

type Election interface {
	Renew(context.Context) error
	Leader(context.Context) (*RoleInfo, error)
	Campaign(context.Context) (ClusterRole, error)
	Resign(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