juju: github.com/juju/juju/worker/lease Index | Files | Directories

package lease

import "github.com/juju/juju/worker/lease"

Index

Package Files

block.go bound.go check.go claim.go config.go manager.go pin.go secretaries.go

func SecretaryFinder Uses

func SecretaryFinder(controllerUUID string) func(string) (Secretary, error)

SecretaryFinder returns a function to find the correct secretary to use for validation for a specific lease namespace (or an error if the namespace isn't valid).

type LeadershipSecretary Uses

type LeadershipSecretary struct{}

LeadershipSecretary implements Secretary; it checks that leases are application names, and holders are unit names.

func (LeadershipSecretary) CheckDuration Uses

func (LeadershipSecretary) CheckDuration(duration time.Duration) error

CheckDuration is part of the lease.Secretary interface.

func (LeadershipSecretary) CheckHolder Uses

func (LeadershipSecretary) CheckHolder(name string) error

CheckHolder is part of the lease.Secretary interface.

func (LeadershipSecretary) CheckLease Uses

func (LeadershipSecretary) CheckLease(key lease.Key) error

CheckLease is part of the lease.Secretary interface.

type Logger Uses

type Logger interface {
    Tracef(string, ...interface{})
    Debugf(string, ...interface{})
    Infof(string, ...interface{})
    Warningf(string, ...interface{})
    Errorf(string, ...interface{})
}

Logger represents the logging methods we use from a loggo.Logger.

type Manager Uses

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

Manager implements worker.Worker and can be bound to get lease.Checkers and lease.Claimers.

func NewDeadManager Uses

func NewDeadManager(err error) *Manager

NewDeadManager returns a manager that's already dead and always returns the given error.

func NewManager Uses

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) Checker Uses

func (manager *Manager) Checker(namespace, modelUUID string) (lease.Checker, error)

Checker returns a lease.Checker for the specified namespace and model.

func (*Manager) Claimer Uses

func (manager *Manager) Claimer(namespace, modelUUID string) (lease.Claimer, error)

Claimer returns a lease.Claimer for the specified namespace and model.

func (*Manager) Kill Uses

func (manager *Manager) Kill()

Kill is part of the worker.Worker interface.

func (*Manager) Pinner Uses

func (manager *Manager) Pinner(namespace, modelUUID string) (lease.Pinner, error)

Pinner returns a lease.Pinner for the specified namespace and model.

func (*Manager) Reader Uses

func (manager *Manager) Reader(namespace, modelUUID string) (lease.Reader, error)

Reader returns a lease.Reader for the specified namespace and model.

func (*Manager) Report Uses

func (manager *Manager) Report() map[string]interface{}

Report is part of dependency.Reporter

func (*Manager) Wait Uses

func (manager *Manager) Wait() error

Wait is part of the worker.Worker interface.

type ManagerConfig Uses

type ManagerConfig struct {

    // Secretary determines validation given a namespace. The
    // secretary returned is responsible for validating lease names
    // and holder names for that namespace.
    Secretary func(namespace string) (Secretary, error)

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

    // Logger is used to report debugging/status information as the
    // manager runs.
    Logger Logger

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

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

    // EntityUUID is the entity that we are running this Manager for. Used for
    // logging purposes.
    EntityUUID string

    // LogDir is the directory to write a debugging log file in the
    // case that the worker times out waiting to shut down.
    LogDir string

    PrometheusRegisterer prometheus.Registerer
}

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

func (ManagerConfig) Validate Uses

func (config ManagerConfig) Validate() error

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

type Secretary Uses

type Secretary interface {

    // CheckLease returns an error if the supplied lease name is not valid.
    CheckLease(key lease.Key) 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 responsible for validating the sanity of lease and holder names before bothering the manager with them.

type SingularSecretary Uses

type SingularSecretary struct {
    ControllerUUID string
}

SingularSecretary implements Secretary to restrict claims to either a lease for the controller or the specific model it's asking for, holdable only by machine-tag strings.

func (SingularSecretary) CheckDuration Uses

func (s SingularSecretary) CheckDuration(duration time.Duration) error

CheckDuration is part of the lease.Secretary interface.

func (SingularSecretary) CheckHolder Uses

func (s SingularSecretary) CheckHolder(name string) error

CheckHolder is part of the lease.Secretary interface.

func (SingularSecretary) CheckLease Uses

func (s SingularSecretary) CheckLease(key lease.Key) error

CheckLease is part of the lease.Secretary interface.

Directories

PathSynopsis
manifold

Package lease imports 18 packages (graph) and is imported by 28 packages. Updated 2019-08-26. Refresh now. Tools for package owners.