leader

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const Type primitive.Type = "LeaderLatch"

Type is the leader latch type

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// GetLatch gets the Latch instance of the given name
	GetLatch(ctx context.Context, name string, opts ...Option) (Latch, error)
}

Client provides an API for creating Latches

type Event

type Event struct {
	// Type is the type of the event
	Type EventType

	// Leadership is the term that occurs as a result of the latch event
	Leadership Leadership
}

Event is an latch event

type EventType

type EventType string

EventType is the type of an Latch event

const (
	// EventChanged indicates the latch term changed
	EventChanged EventType = "changed"
)

type Latch

type Latch interface {
	primitive.Primitive

	// ID returns the ID of the instance of the latch
	ID() string

	// Get gets the current latch
	Get(ctx context.Context) (*Leadership, error)

	// Join joins the latch
	Join(ctx context.Context) (*Leadership, error)

	// Latch attempts to acquire the latch
	Latch(ctx context.Context) (*Leadership, error)

	// Watch watches the latch for changes
	Watch(ctx context.Context, c chan<- *Event) error
}

Latch provides distributed leader latch

func New

func New(ctx context.Context, name primitive.Name, partitions []*primitive.Session, opts ...Option) (Latch, error)

New creates a new latch primitive

type Leadership

type Leadership struct {
	// ID is a globally unique, monotonically increasing term number
	ID uint64

	// Leader is the ID of the leader that was elected
	Leader string

	// Participants is a list of candidates currently participating in the latch
	Participants []string
}

Leadership is a leadership term A term is guaranteed to have a monotonically increasing, globally unique ID.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is a leader latch option

func WithID

func WithID(id string) Option

WithID sets the leader latch instance identifier

Jump to

Keyboard shortcuts

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