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

package machinelock

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


Package Files



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

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). Updated 2019-11-05. Refresh now. Tools for package owners.