unit

package
v0.0.0-...-5168a6d Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2018 License: Apache-2.0 Imports: 15 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Config is a pointer need to be set to the main configuration
	Config *config.ConfigurationInfo

	//EtcdAPI is the etcd keys api
	EtcdAPI interfaces.EtcdAPI = etcdclient.GetEtcdv3()
	// DBusConnection is the connection to the system's D-Bus
	DBusConnection DBusConnectionInterface
	// FS is the file system to be used
	FS = afero.NewOsFs()
)

Functions

func KillAllOldUnits

func KillAllOldUnits()

KillAllOldUnits makes sure all old Dispatch spawned unit files on the system are deleted

Types

type DBusConnectionInterface

type DBusConnectionInterface interface {
	StartUnit(name string, mode string, ch chan<- string) (int, error)
	StopUnit(name string, mode string, ch chan<- string) (int, error)
	KillUnit(name string, signal int32)
	LinkUnitFiles(files []string, runtime bool, force bool) ([]dbus.LinkUnitFileChange, error)
	Reload() error
}

DBusConnectionInterface is the interface of a DBus connection

type Unit

type Unit struct {
	Name         string `json:"name"`
	Machine      string `json:"machine"`
	Template     string `json:"template,omitempty"` // is set with template name if from Template
	Global       string `json:"global,omitempty"`   // is set with global name if from global
	State        state.State
	DesiredState state.State
	Ports        []int64 `json:"ports"`
	Constraints  map[string]string
	UnitContent  string `json:"unitContent"`
	// contains filtered or unexported fields
}

Unit is a struct containing all info of a specific unit

func GetAll

func GetAll() ([]Unit, error)

GetAll returns all units in our zone

func New

func New() Unit

New returns a new Unit

func NewFromEtcd

func NewFromEtcd(name string) Unit

NewFromEtcd creates a new unit with info from etcd

func NewFromEtcdWithCache

func NewFromEtcdWithCache(name string, cache *etcdcache.EtcdCache) Unit

NewFromEtcdWithCache creates a new unit with info from etcd using a specified cache

func (*Unit) Create

func (unit *Unit) Create()

Create writes the unit to the disk

func (*Unit) Destroy

func (unit *Unit) Destroy()

Destroy destroys the given unit

func (*Unit) LoadAndWatch

func (unit *Unit) LoadAndWatch()

LoadAndWatch loads the unit to the system and follows the desired state

func (*Unit) PutOnQueue

func (unit *Unit) PutOnQueue()

PutOnQueue places a specific unit on the queue

func (*Unit) Restart

func (unit *Unit) Restart()

Restart restarts the unit

func (*Unit) SaveOnEtcd

func (unit *Unit) SaveOnEtcd() error

SaveOnEtcd saves the unit to etcd

func (*Unit) SetDesiredState

func (unit *Unit) SetDesiredState(s state.State)

SetDesiredState sets the desiredstate of the unit and updates etcd

func (*Unit) SetState

func (unit *Unit) SetState(s state.State)

SetState sets the state of the unit and updates etcd

func (*Unit) Start

func (unit *Unit) Start()

Start starts the specific unit

func (*Unit) Stop

func (unit *Unit) Stop()

Stop stops the unit

func (*Unit) WaitOnDestroy

func (unit *Unit) WaitOnDestroy()

WaitOnDestroy waits for the unit to enter a destroyed state

func (*Unit) WaitOnState

func (unit *Unit) WaitOnState(s state.State)

WaitOnState waits for the unit to enter a specific state

func (*Unit) Watch

func (unit *Unit) Watch()

Watch creates and etcd watcher for the desired state of a specific unit

type UnitInterface

type UnitInterface interface {
	Start()
	Stop()
	Restart()
	Create()
	PutOnQueue()
	SaveOnEtcd()
	Destroy()
	LoadAndWatch()
	Watch()
	SetState(state.State)
	SetDesiredState(s state.State)
}

UnitInterface is the interface to a Unit

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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