provider

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbortContextMonitoring

type AbortContextMonitoring func()

func NewAbortableMonitoredContext

func NewAbortableMonitoredContext(ctx context.Context) (context.Context, AbortContextMonitoring)

returns a context that monitors the given context for cancellations additionally returns an abort monitoring function that causes the monitoring to stop from that point onwards

type ETCDOption

type ETCDOption func(*etcdLeaseProvider)

func WithETCDConfig added in v0.1.8

func WithETCDConfig(config etcd.Config) ETCDOption

func WithLeaseTTL

func WithLeaseTTL(t int) ETCDOption

in seconds how long should ETCD wait until declaring me dead - in case I crash

func WithUsernamePassword added in v0.1.8

func WithUsernamePassword(username, password string) ETCDOption

type Election

type Election interface {
	Campaign(context.Context, string) error
	ReassureLeadership(context.Context, string) error
	Resign(context.Context) error
}

type ElectionMetaDataProvider

type ElectionMetaDataProvider interface {
	// identifying the locking key during election - the lowest denominator of lock
	Constituency(shard string) string
	// value that is used during campaigning for leadership
	CampaignPromise() string
	// value that is used as a part of a heartbeat during leadership
	LeadershipReassurance(electedAt time.Time) string
}

type Lease

type Lease interface {
	ID() string
	Expired() <-chan struct{}
	ElectionFor(constituency string) Election
	Close()
}

type LeaseProvider

type LeaseProvider interface {
	// if context is cancelled, return an error; otherwise block forever until lease is acquired
	// returning before a lease is acquired and the context still active will be considered a bugs
	AcquireLease(context.Context) (Lease, error)
}

A LeaseProvider implementation is backed by a remote endpoint used to implement a distributed lock. It facilitates the acquisition of a Lease that indicates liveness of the client as well as the server. The LeaseProvider should continuously renew it's lease before expiration via a heartbeat of some sort. From a client perspective if the remote endpoint is no longer available or for other reasons indicated by the server, an acquired lease should be expired. From a server perspective if a lease exprires, other lease holders can acquire locks previously held by the expiring lease holder.

func NewETCDLeaseProvider

func NewETCDLeaseProvider(etcdEndPoints []string, options ...ETCDOption) LeaseProvider

etcd backed LeaseProvider

Jump to

Keyboard shortcuts

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