lease

package
v0.0.0-...-6cf1bc9 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2016 License: AGPL-3.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 Manager

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

Manager implements lease.Claimer, lease.Checker, and worker.Worker.

func NewManager

func NewManager(config ManagerConfig) (*Manager, error)

NewManager returns a new *Manager configured as supplied. The caller takes responsibility for killing, and handling errors from, the returned Worker.

func (*Manager) Claim

func (manager *Manager) Claim(leaseName, holderName string, duration time.Duration) error

Claim is part of the lease.Claimer interface.

func (*Manager) Kill

func (manager *Manager) Kill()

Kill is part of the worker.Worker interface.

func (*Manager) Token

func (manager *Manager) Token(leaseName, holderName string) lease.Token

Token is part of the lease.Checker interface.

func (*Manager) Wait

func (manager *Manager) Wait() error

Wait is part of the worker.Worker interface.

func (*Manager) WaitUntilExpired

func (manager *Manager) WaitUntilExpired(leaseName string) error

WaitUntilExpired is part of the lease.Claimer interface.

type ManagerConfig

type ManagerConfig struct {

	// Secretary is responsible for validating lease names and holder names.
	Secretary Secretary

	// Client is responsible for recording, retrieving, and expiring leases.
	Client lease.Client

	// Clock is reponsible for reporting the passage of time.
	Clock clock.Clock

	// MaxSleep is the longest time the Manager should sleep before
	// refreshing its client's leases and checking for expiries.
	MaxSleep time.Duration
}

ManagerConfig contains the resources and information required to create a Manager.

func (ManagerConfig) Validate

func (config ManagerConfig) Validate() error

Validate returns an error if the configuration contains invalid information or missing resources.

type Secretary

type Secretary interface {

	// CheckLease returns an error if the supplied lease name is not valid.
	CheckLease(name string) error

	// CheckHolder returns an error if the supplied holder name is not valid.
	CheckHolder(name string) error

	// CheckDuration returns an error if the supplied duration is not valid.
	CheckDuration(duration time.Duration) error
}

Secretary is reponsible for validating the sanity of lease and holder names before bothering the manager with them.

Jump to

Keyboard shortcuts

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