juju: github.com/juju/juju/core/machinelock Index | Files

package machinelock

import "github.com/juju/juju/core/machinelock"

Index

Package Files

machinelock.go

Constants

const Filename = "machine-lock.log"

Filename represents the name of the logfile that is created in the LOG_DIR.

func New Uses

func New(config Config) (*lock, error)

New creates a new machine lock.

type Clock Uses

type Clock interface {
    // After waits for the duration to elapse and then sends the
    // current time on the returned channel.
    After(time.Duration) <-chan time.Time

    // Now returns the current clock time.
    Now() time.Time
}

Clock provides an interface for dealing with clocks.

type Config Uses

type Config struct {
    AgentName   string
    Clock       Clock
    Logger      Logger
    LogFilename string
}

Config defines the attributes needed to correctly construct a machine lock.

func (Config) Validate Uses

func (c Config) Validate() error

Validate ensures that all the required config values are set.

type Lock Uses

type Lock interface {
    Acquire(spec Spec) (func(), error)
    Report(opts ...ReportOption) (string, error)
}

Lock is used to give external packages something to refer to.

type Logger Uses

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

Logger defines the logging methods used by the machine lock.

type ReportOption Uses

type ReportOption int
const (
    ShowHistory ReportOption = iota
    ShowStack
    ShowDetailsYAML
)

type Spec Uses

type Spec struct {
    Cancel <-chan struct{}
    // The purpose of the NoCancel is to ensure that there isn't
    // an accidental forgetting of the cancel channel. The primary
    // use case for this is the reboot worker that doesn't want to
    // pass in a cancel channel because it really wants to reboot.
    NoCancel bool
    Worker   string
    Comment  string
}

Spec is an argument struct for the `Acquire` method. It must have a Cancel channel and a Worker name defined.

func (Spec) Validate Uses

func (s Spec) Validate() error

Validate ensures that a Cancel channel and a Worker name are defined.

Package machinelock imports 11 packages (graph) and is imported by 42 packages. Updated 2019-10-22. Refresh now. Tools for package owners.