system

package
v0.2.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2019 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(data *userdata.UserData) *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 HealthcheckedService

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

HealthcheckedService is a service which provides health check

type Service

type Service interface {
	// ID is the service id.
	ID(*userdata.UserData) string
	// PreFunc is invoked before a runner is created
	PreFunc(context.Context, *userdata.UserData) error
	// Runner creates runner for the service
	Runner(*userdata.UserData) (runner.Runner, error)
	// PostFunc is invoked after a runner is closed.
	PostFunc(*userdata.UserData) error
	// Condition describes the conditions under which a service should
	// start.
	Condition(*userdata.UserData) conditions.Condition
	// DependsOn returns list of service IDs this service depends on.
	DependsOn(*userdata.UserData) []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, userData *userdata.UserData) *ServiceRunner

NewServiceRunner creates new ServiceRunner around Service instance

func (*ServiceRunner) AsProto

func (svcrunner *ServiceRunner) AsProto() *proto.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) 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
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