Documentation ¶
Index ¶
- Constants
- Variables
- func Services(data *userdata.UserData) *singleton
- func WaitForService(event StateEvent, service string) conditions.Condition
- type HealthcheckedService
- type Service
- type ServiceRunner
- func (svcrunner *ServiceRunner) AsProto() *proto.ServiceInfo
- func (svcrunner *ServiceRunner) GetEventHistory(count int) []events.ServiceEvent
- func (svcrunner *ServiceRunner) Shutdown()
- func (svcrunner *ServiceRunner) Start()
- func (svcrunner *ServiceRunner) Subscribe(event StateEvent, ch chan<- struct{})
- func (svcrunner *ServiceRunner) Unsubscribe(event StateEvent, ch chan<- struct{})
- func (svcrunner *ServiceRunner) UpdateState(newstate events.ServiceState, message string, args ...interface{})
- type StateEvent
Constants ¶
const ( StateEventUp = StateEvent("up") StateEventDown = StateEvent("down") )
Service event list
Variables ¶
var WaitConditionCheckInterval = time.Second
WaitConditionCheckInterval is time between checking for wait condition description changes.
Exposed here for unit-tests to override
Functions ¶
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
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 |