leader

package
v0.5.0-beta3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConstElectionFactory

type ConstElectionFactory struct {
	ConstID string
}

func (*ConstElectionFactory) NewElection

func (factory *ConstElectionFactory) NewElection(ctx context.Context, sequence int64) (Election, error)

type Election

type Election struct {
	Sequence int64
	ElectID  string
}

type ElectionFactory

type ElectionFactory interface {
	NewElection(ctx context.Context, sequence int64) (Election, error)
}

type ElectionFactoryFunc added in v0.3.0

type ElectionFactoryFunc func(ctx context.Context, sequence int64) (Election, error)

func (ElectionFactoryFunc) NewElection added in v0.3.0

func (fun ElectionFactoryFunc) NewElection(ctx context.Context, sequence int64) (Election, error)

type Elector

type Elector interface {
	PostElection(ctx context.Context, election Election) error
	KeepLive(ctx context.Context, keepLive KeepLive) error
	WaitElectionNotify(ctx context.Context) (Election, error)
}

type KeepLive

type KeepLive struct {
	Sequence int64
	ElectID  string
}

type Leaders

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

func NewLeaders

func NewLeaders(partitions ...*Partition) *Leaders

func (*Leaders) AllPartitions

func (pl *Leaders) AllPartitions() []PartitionID

func (*Leaders) SyncLeader

func (pl *Leaders) SyncLeader(ctx context.Context, executor PartitionExecutor)

type Member

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

func NewMember

func NewMember(elector Elector, electFactory ElectionFactory, option Option) *Member

func (*Member) CloseWithContext

func (mb *Member) CloseWithContext(ctx context.Context) error

func (*Member) DoAsLeader

func (mb *Member) DoAsLeader(ctx context.Context, do func(ctx context.Context)) bool

func (*Member) GetInfo added in v0.3.0

func (mb *Member) GetInfo() MemberInfo

func (*Member) Start added in v0.3.0

func (mb *Member) Start() bool

func (*Member) SyncLeader added in v0.3.0

func (mb *Member) SyncLeader(ctx context.Context, do func(ctx context.Context))

block and run do until leader, return if not leader

type MemberInfo

type MemberInfo struct {
	LeaderID   string
	IsLeader   bool
	ElectionID string
	Sequence   int64
}

type MemoDecider

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

func NewMemoDecider

func NewMemoDecider() *MemoDecider

func (*MemoDecider) CreateElector

func (decider *MemoDecider) CreateElector() *MemoElector

type MemoElector added in v0.3.0

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

func (*MemoElector) KeepLive added in v0.3.0

func (elector *MemoElector) KeepLive(ctx context.Context, keepLive KeepLive) error

func (*MemoElector) PostElection added in v0.3.0

func (elector *MemoElector) PostElection(ctx context.Context, election Election) error

func (*MemoElector) WaitElectionNotify added in v0.3.0

func (elector *MemoElector) WaitElectionNotify(ctx context.Context) (Election, error)

type Middle

type Middle interface {
	WrapElector(elector Elector) Elector
}

func NewRecorderMiddle

func NewRecorderMiddle(factory record.Factory) Middle

type Option

type Option struct {
	MaxElectDuration    time.Duration
	MinElectDuration    time.Duration
	MaxKeepLiveDuration time.Duration
	MinKeepLiveDuration time.Duration

	MaxExecDuration time.Duration
	MinExecDuration time.Duration
}

type Partition

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

func NewPartition

func NewPartition(id PartitionID, member *Member, vars map[string]string) *Partition

func (*Partition) GetValue

func (part *Partition) GetValue(key string) string

func (*Partition) ID

func (part *Partition) ID() PartitionID

type PartitionExecutor

type PartitionExecutor func(ctx context.Context, partition *Partition)

type PartitionID added in v0.3.0

type PartitionID int64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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