unit

package
v0.0.0-...-16b8bb0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package unit defines unit types, which system.Interface can supervise

Index

Constants

This section is empty.

Variables

View Source
var ErrNotExist = errors.New("Does not exist")
View Source
var ErrNotParsed = errors.New("Unit definition is not parsed properly")
View Source
var ErrNotSet = errors.New("Field not specified")
View Source
var ErrNotStarted = errors.New("Unit not started")
View Source
var ErrNotSupported = errors.New("Not supported")
View Source
var ErrPathNotAbs = errors.New("Path specified is not absolute")
View Source
var ErrUnknownType = errors.New("Unknown type")
View Source
var ErrWrongVal = errors.New("Wrong value received")

Functions

func IsActive

func IsActive(u Subber) bool

func ParseDefinition

func ParseDefinition(r io.Reader, v interface{}) (err error)

ParseDefinition parses the data in Systemd unit-file format and stores the result in value pointed by Definition

Types

type Activation

type Activation int

Activation status of a unit -- https://goo.gl/XHBVuC

const (
	Inactive Activation = iota
	Active
	Reloading
	Failed
	Activating
	Deactivating
)

type ActivationStatus

type ActivationStatus struct {
	State Activation `json:"State"`
	Sub   string     `json:"Sub"`
}

type Definer

type Definer interface {
	Define(io.Reader) error
}

type Definition

type Definition struct {
	Unit struct {
		Description                               string
		Documentation                             string
		Wants, Requires, Conflicts, Before, After []string
	}
	Install struct {
		WantedBy, RequiredBy []string
	}
}

Definition of a unit matching the fields found in unit-file

func (Definition) After

func (def Definition) After() []string

After returns a slice of unit names as found in Definition

func (Definition) Before

func (def Definition) Before() []string

Before returns a slice of unit names as found in Definition

func (Definition) Conflicts

func (def Definition) Conflicts() []string

Conflicts returns a slice of unit names as found in Definition

func (Definition) Description

func (def Definition) Description() string

Description returns a string as found in Definition

func (Definition) Documentation

func (def Definition) Documentation() string

Documentation returns a string as found in Definition

func (Definition) RequiredBy

func (def Definition) RequiredBy() []string

RequiredBy returns a slice of unit names as found in Definition

func (Definition) Requires

func (def Definition) Requires() []string

Requires returns a slice of unit names as found in Definition

func (Definition) WantedBy

func (def Definition) WantedBy() []string

WantedBy returns a slice of unit names as found in Definition

func (Definition) Wants

func (def Definition) Wants() []string

Wants returns a slice of unit names as found in Definition

type Dependency

type Dependency interface {
	Wants() []string
	Requires() []string

	Conflicts() []string

	RequiredBy() []string
	WantedBy() []string

	After() []string
	Before() []string
}

type Enable

type Enable int

Enable status of a unit

const (
	Disabled Enable = iota
	Static
	Indirect
	Enabled
)

type Interface

type Interface interface {
	Definer
	Subber

	Description() string
	Documentation() string

	Dependency
}

type Load

type Load int

Load status of a unit definition file -- https://goo.gl/NRBCVK

const (
	Stub Load = iota
	Loaded
	NotFound
	Error
	Merged
	Masked
)

type LoadStatus

type LoadStatus struct {
	Path   string `json:"Path"`
	Loaded Load   `json:"Loaded"`
	State  Enable `json:"Enabled"`
	Vendor Enable `json:"Vendor"`
}

type MultiError

type MultiError []error

func (MultiError) Error

func (m MultiError) Error() string

func (MultiError) Errors

func (m MultiError) Errors() (errs []string)

type ParseError

type ParseError struct {
	Source string
	Err    error
}

func ParseErr

func ParseErr(source string, err error) ParseError

func (ParseError) Error

func (err ParseError) Error() string

type Reloader

type Reloader interface {
	Reload() error
}

Reloader is implemented by any value capable of reloading itself(or its definition)

type StartStopper

type StartStopper interface {
	Starter
	Stopper
}

StartStopper is implemented by any value that has Start and Stop methods

type Starter

type Starter interface {
	Start() error
}

Starter is implemented by any value that has a Start method

type Status

type Status struct {
	Load       LoadStatus       `json:"Load"`
	Activation ActivationStatus `json:"Activation"`

	Log []byte `json:"Log,omitempty"`
}

func (Status) String

func (s Status) String() (out string)

type Stopper

type Stopper interface {
	Stop() error
}

Stopper is implemented by any value that has a Stop method

type Subber

type Subber interface {
	Active() Activation
	Sub() string
}

Subber is implemented by any value that has Sub and Active methods

Directories

Path Synopsis
Package service defines a service unit type
Package service defines a service unit type

Jump to

Keyboard shortcuts

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