registry

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2015 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Occurs when any Job's target is touched
	JobTargetChangeEvent = pkg.Event("JobTargetChangeEvent")
	// Occurs when any Job's target state is touched
	JobTargetStateChangeEvent = pkg.Event("JobTargetStateChangeEvent")
)
View Source
const DefaultKeyPrefix = "/_coreos.com/fleet/"

Variables

This section is empty.

Functions

func NewEtcdEventStream

func NewEtcdEventStream(client etcd.Client, rootPrefix string) pkg.EventStream

Types

type ClusterRegistry

type ClusterRegistry interface {
	LatestDaemonVersion() (*semver.Version, error)

	// EngineVersion returns the current version of the cluster. If the
	// cluster does not yet have a version, zero will be returned. If
	// any error occurs, an error object will be returned. In this case,
	// the returned version number should be ignored.
	EngineVersion() (int, error)

	// UpdateEngineVersion attempts to compare-and-swap the cluster version
	// from one value to another. Any failures in this process will be
	// indicated by the returned error object. A nil value will be returned
	// on success.
	UpdateEngineVersion(from, to int) error
}

type EtcdRegistry

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

EtcdRegistry fulfils the Registry interface and uses etcd as a backend

func NewEtcdRegistry

func NewEtcdRegistry(client etcd.Client, keyPrefix string) *EtcdRegistry

func (*EtcdRegistry) AcquireLease

func (r *EtcdRegistry) AcquireLease(name string, machID string, ver int, period time.Duration) (Lease, error)

func (*EtcdRegistry) ClearUnitHeartbeat

func (r *EtcdRegistry) ClearUnitHeartbeat(name string)

func (*EtcdRegistry) CreateUnit

func (r *EtcdRegistry) CreateUnit(u *job.Unit) (err error)

CreateUnit attempts to store a Unit and its associated unit file in the registry

func (*EtcdRegistry) DestroyUnit

func (r *EtcdRegistry) DestroyUnit(name string) error

DestroyUnit removes a Job object from the repository. It does not yet remove underlying UnitFiles from the repository.

func (*EtcdRegistry) EngineVersion

func (r *EtcdRegistry) EngineVersion() (int, error)

EngineVersion implements the ClusterRegistry interface

func (*EtcdRegistry) GetLease

func (r *EtcdRegistry) GetLease(name string) (Lease, error)

func (*EtcdRegistry) LatestDaemonVersion

func (r *EtcdRegistry) LatestDaemonVersion() (*semver.Version, error)

LatestDaemonVersion attempts to retrieve the latest version of fleetd that has been registered in the Registry. It returns the version if it can be determined (or nil otherwise), and any error encountered.

func (*EtcdRegistry) Machines

func (r *EtcdRegistry) Machines() (machines []machine.MachineState, err error)

func (*EtcdRegistry) RemoveMachineState

func (r *EtcdRegistry) RemoveMachineState(machID string) error

func (*EtcdRegistry) RemoveUnitState

func (r *EtcdRegistry) RemoveUnitState(jobName string) error

Delete the state from the Registry for the given Job's Unit

func (*EtcdRegistry) SaveUnitState

func (r *EtcdRegistry) SaveUnitState(jobName string, unitState *unit.UnitState, ttl time.Duration)

SaveUnitState persists the given UnitState to the Registry

func (*EtcdRegistry) Schedule

func (r *EtcdRegistry) Schedule() ([]job.ScheduledUnit, error)

Schedule returns all ScheduledUnits known by fleet, ordered by name

func (*EtcdRegistry) ScheduleUnit

func (r *EtcdRegistry) ScheduleUnit(name string, machID string) error

func (*EtcdRegistry) ScheduledUnit

func (r *EtcdRegistry) ScheduledUnit(name string) (*job.ScheduledUnit, error)

ScheduledUnit retrieves the ScheduledUnit by the given name from the Registry. Returns nil if no such ScheduledUnit exists, and any error encountered.

func (*EtcdRegistry) SetMachineState

func (r *EtcdRegistry) SetMachineState(ms machine.MachineState, ttl time.Duration) (uint64, error)

func (*EtcdRegistry) SetUnitTargetState

func (r *EtcdRegistry) SetUnitTargetState(name string, state job.JobState) error

func (*EtcdRegistry) StealLease

func (r *EtcdRegistry) StealLease(name, machID string, ver int, period time.Duration, idx uint64) (Lease, error)

func (*EtcdRegistry) Unit

func (r *EtcdRegistry) Unit(name string) (*job.Unit, error)

Unit retrieves the Unit by the given name from the Registry. Returns nil if no such Unit exists, and any error encountered.

func (*EtcdRegistry) UnitHeartbeat

func (r *EtcdRegistry) UnitHeartbeat(name, machID string, ttl time.Duration) error

func (*EtcdRegistry) UnitStates

func (r *EtcdRegistry) UnitStates() (states []*unit.UnitState, err error)

UnitStates returns a list of all UnitStates stored in the registry, sorted by unit name and then machine ID.

func (*EtcdRegistry) Units

func (r *EtcdRegistry) Units() ([]job.Unit, error)

Units lists all Units stored in the Registry, ordered by name. This includes both global and non-global units.

func (*EtcdRegistry) UnscheduleUnit

func (r *EtcdRegistry) UnscheduleUnit(name, machID string) error

func (*EtcdRegistry) UpdateEngineVersion

func (r *EtcdRegistry) UpdateEngineVersion(from, to int) error

UpdateEngineVersion implements the ClusterRegistry interface

type FakeClusterRegistry

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

func NewFakeClusterRegistry

func NewFakeClusterRegistry(dVersion *semver.Version, eVersion int) *FakeClusterRegistry

func (*FakeClusterRegistry) EngineVersion

func (fc *FakeClusterRegistry) EngineVersion() (int, error)

func (*FakeClusterRegistry) LatestDaemonVersion

func (fc *FakeClusterRegistry) LatestDaemonVersion() (*semver.Version, error)

func (*FakeClusterRegistry) UpdateEngineVersion

func (fc *FakeClusterRegistry) UpdateEngineVersion(from, to int) error

type FakeLeaseRegistry

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

func NewFakeLeaseRegistry

func NewFakeLeaseRegistry() *FakeLeaseRegistry

func (*FakeLeaseRegistry) AcquireLease

func (fl *FakeLeaseRegistry) AcquireLease(name, machID string, ver int, ttl time.Duration) (Lease, error)

func (*FakeLeaseRegistry) GetLease

func (fl *FakeLeaseRegistry) GetLease(name string) (Lease, error)

func (*FakeLeaseRegistry) SetLease

func (fl *FakeLeaseRegistry) SetLease(name, machID string, ver int, ttl time.Duration) *fakeLease

func (*FakeLeaseRegistry) StealLease

func (fl *FakeLeaseRegistry) StealLease(name, machID string, ver int, ttl time.Duration, idx uint64) (Lease, error)

type FakeRegistry

type FakeRegistry struct {
	// Not all methods required by the Registry interface are implemented
	// by the FakeRegistry. Any calls to these unimplemented methods will
	// result in a panic.
	Registry
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewFakeRegistry

func NewFakeRegistry() *FakeRegistry

func (*FakeRegistry) ClearUnitHeartbeat

func (f *FakeRegistry) ClearUnitHeartbeat(string)

func (*FakeRegistry) CreateUnit

func (f *FakeRegistry) CreateUnit(u *job.Unit) error

func (*FakeRegistry) DestroyUnit

func (f *FakeRegistry) DestroyUnit(name string) error

func (*FakeRegistry) Machines

func (f *FakeRegistry) Machines() ([]machine.MachineState, error)

func (*FakeRegistry) RemoveUnitState

func (f *FakeRegistry) RemoveUnitState(jobName string) error

func (*FakeRegistry) SaveUnitState

func (f *FakeRegistry) SaveUnitState(jobName string, unitState *unit.UnitState, ttl time.Duration)

func (*FakeRegistry) Schedule

func (f *FakeRegistry) Schedule() ([]job.ScheduledUnit, error)

func (*FakeRegistry) ScheduleUnit

func (f *FakeRegistry) ScheduleUnit(name string, machID string) error

func (*FakeRegistry) ScheduledUnit

func (f *FakeRegistry) ScheduledUnit(name string) (*job.ScheduledUnit, error)

func (*FakeRegistry) SetJobs

func (f *FakeRegistry) SetJobs(jobs []job.Job)

func (*FakeRegistry) SetMachines

func (f *FakeRegistry) SetMachines(machines []machine.MachineState)

func (*FakeRegistry) SetUnitStates

func (f *FakeRegistry) SetUnitStates(states []unit.UnitState)

func (*FakeRegistry) SetUnitTargetState

func (f *FakeRegistry) SetUnitTargetState(name string, target job.JobState) error

func (*FakeRegistry) Unit

func (f *FakeRegistry) Unit(name string) (*job.Unit, error)

func (*FakeRegistry) UnitHeartbeat

func (f *FakeRegistry) UnitHeartbeat(name, machID string, ttl time.Duration) error

func (*FakeRegistry) UnitStates

func (f *FakeRegistry) UnitStates() ([]*unit.UnitState, error)

func (*FakeRegistry) Units

func (f *FakeRegistry) Units() ([]job.Unit, error)

type Lease

type Lease interface {
	// Renew attempts to extend the Lease TTL to the provided duration.
	// The operation will succeed only if the Lease has not changed in
	// the LeaseRegistry since it was last renewed or first acquired.
	// An error is returned if the Lease has already expired, or if the
	// operation fails for any other reason.
	Renew(time.Duration) error

	// Release relinquishes the ownership of a Lease back to the Registry.
	// After calling Release, the Lease object should be discarded. An
	// error is returned if the Lease has already expired, or if the
	// operation fails for any other reason.
	Release() error

	// MachineID returns the ID of the Machine that holds this Lease. This
	// value must be considered a cached value as it is not guaranteed to
	// be correct.
	MachineID() string

	// Version returns the current version at which the lesse is operating.
	// This value has the same correctness guarantees as MachineID.
	// It is up to the caller to determine what this Version means.
	Version() int

	// Index exposes the relative time at which the Lease was created or
	// renewed. For example, this could be implemented as the ModifiedIndex
	// field of a node in etcd.
	Index() uint64

	// TimeRemaining represents the amount of time left on the Lease when
	// it was fetched from the LeaseRegistry.
	TimeRemaining() time.Duration
}

Lease proxies to an auto-expiring lease stored in a LeaseRegistry. The creator of a Lease must repeatedly call Renew to keep their lease from expiring.

type LeaseRegistry

type LeaseRegistry interface {
	// GetLease fetches a Lease only if it exists. If it does not
	// exist, a nil Lease will be returned. Any other failures
	// result in non-nil error and nil Lease objects.
	GetLease(name string) (Lease, error)

	// AcquireLease acquires a named lease only if the lease is not
	// currently held. If a Lease cannot be acquired, a nil Lease
	// object is returned. An error is returned only if there is a
	// failure communicating with the Registry.
	AcquireLease(name, machID string, ver int, period time.Duration) (Lease, error)

	// StealLease attempts to replace the lessee of the Lease identified
	// by the provided name and index with a new lessee. This function
	// will fail if the named Lease has progressed past the given index.
	StealLease(name, machID string, ver int, period time.Duration, idx uint64) (Lease, error)
}

type MUSKey

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

MUSKey is used to index UnitStates by name + machineID

type MUSKeys

type MUSKeys []MUSKey

MUSKeys provides for sorting of UnitStates by their MUSKey

func (MUSKeys) Len

func (mk MUSKeys) Len() int

func (MUSKeys) Less

func (mk MUSKeys) Less(i, j int) bool

func (MUSKeys) Swap

func (mk MUSKeys) Swap(i, j int)

type Registry

type Registry interface {
	ClearUnitHeartbeat(name string)
	CreateUnit(*job.Unit) error
	DestroyUnit(string) error
	UnitHeartbeat(name, machID string, ttl time.Duration) error
	Machines() ([]machine.MachineState, error)
	RemoveMachineState(machID string) error
	RemoveUnitState(jobName string) error
	SaveUnitState(jobName string, unitState *unit.UnitState, ttl time.Duration)
	ScheduleUnit(name, machID string) error
	SetUnitTargetState(name string, state job.JobState) error
	SetMachineState(ms machine.MachineState, ttl time.Duration) (uint64, error)
	UnscheduleUnit(name, machID string) error

	UnitRegistry
}

type UnitRegistry

type UnitRegistry interface {
	Schedule() ([]job.ScheduledUnit, error)
	ScheduledUnit(name string) (*job.ScheduledUnit, error)
	Unit(name string) (*job.Unit, error)
	Units() ([]job.Unit, error)
	UnitStates() ([]*unit.UnitState, error)
}

Jump to

Keyboard shortcuts

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