election

package
v0.2.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tracker

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

Tracker tracks mastership of a collection of resources.

func NewTracker

func NewTracker(factory election2.Factory, maxHold time.Duration, metricFactory monitoring.MetricFactory) *Tracker

NewTracker returns a new mastership tracker.

func (*Tracker) AddResource

func (mt *Tracker) AddResource(res string)

AddResource makes the mastership tracker aware of new resources. The same resource may be added an unlimited number of times.

func (*Tracker) Masterships

func (mt *Tracker) Masterships(ctx context.Context) (map[string]context.Context, error)

Masterships returns a map of resources to mastership contexts. Callers should cancel ctx when they no longer are actively using mastership. If Masterships is not called periodically, we may retain masterships for longer than maxHold.

func (*Tracker) Run

func (mt *Tracker) Run(ctx context.Context)

Run starts new watchers for new resources.

Jump to

Keyboard shortcuts

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