system

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2020 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateEventUp   = StateEvent("up")
	StateEventDown = StateEvent("down")
)

Service event list

Variables

View Source
var WaitConditionCheckInterval = time.Second

WaitConditionCheckInterval is time between checking for wait condition description changes.

Exposed here for unit-tests to override

Functions

func Services

func Services(config runtime.Configurator) *singleton

Services returns the instance of the system services API. nolint: golint

func WaitForService

func WaitForService(event StateEvent, service string) conditions.Condition

WaitForService waits for service to reach some state event

Types

type APIRestartableService

type APIRestartableService interface {
	APIRestartAllowed(runtime.Configurator) bool
}

APIRestartableService is a service which allows to be restarted via API

type APIStartableService

type APIStartableService interface {
	APIStartAllowed(runtime.Configurator) bool
}

APIStartableService is a service which allows to be started via API

type APIStoppableService

type APIStoppableService interface {
	APIStopAllowed(runtime.Configurator) bool
}

APIStoppableService is a service which allows to be stopped via API

type HealthcheckedService

type HealthcheckedService interface {
	// HealtFunc provides function that checks health of the service
	HealthFunc(runtime.Configurator) health.Check
	// HealthSettings returns settings for the health check
	HealthSettings(runtime.Configurator) *health.Settings
}

HealthcheckedService is a service which provides health check

type Service

type Service interface {
	// ID is the service id.
	ID(runtime.Configurator) string
	// PreFunc is invoked before a runner is created
	PreFunc(context.Context, runtime.Configurator) error
	// Runner creates runner for the service
	Runner(runtime.Configurator) (runner.Runner, error)
	// PostFunc is invoked after a runner is closed.
	PostFunc(runtime.Configurator, events.ServiceState) error
	// Condition describes the conditions under which a service should
	// start.
	Condition(runtime.Configurator) conditions.Condition
	// DependsOn returns list of service IDs this service depends on.
	DependsOn(runtime.Configurator) []string
}

Service is an interface describing a system service.

type ServiceRunner

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

ServiceRunner wraps the state of the service (running, stopped, ...)

func NewServiceRunner

func NewServiceRunner(service Service, config runtime.Configurator) *ServiceRunner

NewServiceRunner creates new ServiceRunner around Service instance

func (*ServiceRunner) AsProto

func (svcrunner *ServiceRunner) AsProto() *machineapi.ServiceInfo

AsProto returns protobuf struct with the state of the service runner

func (*ServiceRunner) GetEventHistory

func (svcrunner *ServiceRunner) GetEventHistory(count int) []events.ServiceEvent

GetEventHistory returns history of events for this service

func (*ServiceRunner) GetState added in v0.4.0

func (svcrunner *ServiceRunner) GetState() events.ServiceState

GetState implements events.Recorder

func (*ServiceRunner) Shutdown

func (svcrunner *ServiceRunner) Shutdown()

Shutdown initiates shutdown of the service runner

Shutdown completes when Start() returns

func (*ServiceRunner) Start

func (svcrunner *ServiceRunner) Start()

Start initializes the service and runs it

Start should be run in a goroutine. nolint: gocyclo

func (*ServiceRunner) Subscribe

func (svcrunner *ServiceRunner) Subscribe(event StateEvent, ch chan<- struct{})

Subscribe to a specific event for this service.

Channel `ch` should be buffered or it should have listener attached to it, as event might be delivered before Subscribe() returns.

func (*ServiceRunner) Unsubscribe

func (svcrunner *ServiceRunner) Unsubscribe(event StateEvent, ch chan<- struct{})

Unsubscribe cancels subscription established with Subscribe.

func (*ServiceRunner) UpdateState

func (svcrunner *ServiceRunner) UpdateState(newstate events.ServiceState, message string, args ...interface{})

UpdateState implements events.Recorder

type StateEvent

type StateEvent string

StateEvent is a service event (e.g. 'up', 'down')

Directories

Path Synopsis
cri
Package cri implements runner via CRI interface
Package cri implements runner via CRI interface
nolint: dupl,golint nolint: dupl,golint nolint: dupl,golint nolint: dupl,golint nolint: dupl,golint nolint: dupl,golint nolint: dupl,golint
nolint: dupl,golint nolint: dupl,golint nolint: dupl,golint nolint: dupl,golint nolint: dupl,golint nolint: dupl,golint nolint: dupl,golint

Jump to

Keyboard shortcuts

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