cluster

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathMember    = "member"
	PathHeartbeat = "heartbeat"
	PathLeader    = "leader"
)
View Source
const (
	MemberChangedEventPath = types.EventPath("member-changed")
	LeaderChangedEventPath = types.EventPath("leader-changed")
)

Variables

View Source
var (
	NilMember = Member{}
)

Functions

This section is empty.

Types

type Cluster

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

Cluster ..

func (*Cluster) GetAliveMemberIDs

func (cluster *Cluster) GetAliveMemberIDs() []string

GetAliveMemberIDs get active member IDs

func (*Cluster) GetAliveMembers

func (cluster *Cluster) GetAliveMembers() []*Member

GetAliveMembers get active members

func (*Cluster) GetMember

func (cluster *Cluster) GetMember(id string) *Member

GetMember get member with given name

func (*Cluster) GetSortedMembers

func (cluster *Cluster) GetSortedMembers() []string

GetSortedMembers get all member ids

func (*Cluster) IsLeader

func (cluster *Cluster) IsLeader() bool

Local get localMember

func (*Cluster) Leader

func (cluster *Cluster) Leader() *Member

Leader get Leader

func (*Cluster) Local

func (cluster *Cluster) Local() *Member

Local get localMember

func (*Cluster) Name

func (cluster *Cluster) Name() string

Name get name

type LeaderChangedEvent

type LeaderChangedEvent struct {
	common.DaemonEvent
	IsLeader bool
	Leader   *Member
}

func (LeaderChangedEvent) Path

func (event LeaderChangedEvent) Path() types.EventPath

type Manager

type Manager struct {
	common.Context
	// contains filtered or unexported fields
}

func NewManager

func NewManager(context common.Context) *Manager

func (*Manager) GetCluster

func (manager *Manager) GetCluster() *Cluster

GetCluster get cluster

func (*Manager) IsLeaderNode

func (manager *Manager) IsLeaderNode() bool

IsLeaderNode : returns whether this kernel is leader.

func (*Manager) Start

func (manager *Manager) Start()

type Member

type Member struct {
	NodeID string `json:"nodeid"`
	Name   string `json:"name"`
	// contains filtered or unexported fields
}

Member member info

func NewMember

func NewMember(name string, nodeid string) *Member

func (*Member) Heartbeat

func (m *Member) Heartbeat() time.Time

SetLocal Set member alive

func (*Member) IsAlive

func (m *Member) IsAlive() bool

IsAlive return whether member is alive

func (*Member) IsLeader

func (m *Member) IsLeader() bool

IsLeader return whether member is leader

func (*Member) IsLocal

func (m *Member) IsLocal() bool

IsLocal return whether member is alive

func (*Member) SetAlive

func (m *Member) SetAlive(alive bool)

SetAlive Set member alive

func (*Member) SetHeartbeat

func (m *Member) SetHeartbeat(time time.Time)

SetLocal Set member alive

func (*Member) SetLeader

func (m *Member) SetLeader(leader bool)

SetLeader Set member as leader

func (*Member) SetLocal

func (m *Member) SetLocal(local bool)

SetLocal Set member alive

func (*Member) String

func (m *Member) String() string

String implement fmt.Stringer

type MemberChangedEvent

type MemberChangedEvent struct {
	common.DaemonEvent
	IsLeader       bool
	AliveMemberIDs []string
	AliveMembers   []*Member
}

func (MemberChangedEvent) Path

func (event MemberChangedEvent) Path() types.EventPath

type Repository

type Repository interface {
	PutMember(member *Member) (err error)
	GetMember(nodeID string) (member Member, err error)
	HasMember(nodeID string) (ok bool)
	PutLeader(leader string) (err error)
	GetLeader() (leader string, err error)
	GetAllMembers() (members []*Member, err error)
	PutHeartbeat(nodeID string) (err error)
	GetHeartbeats(handler func(nodeid string, time time.Time)) (err error)
}

func NewRepository

func NewRepository(config common.DaemonConfig, logger log.Logger, client types.Client) Repository

Jump to

Keyboard shortcuts

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