Documentation
¶
Overview ¶
Package types exports public types for lifecycle.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultRestartPolicy = ServiceRestartPolicy{ RestartOnFailure: true, RestartCount: 4, RestartDelay: time.Millisecond * 100, }
DefaultRestartPolicy is a default restart policy for services.
Functions ¶
This section is empty.
Types ¶
type ServiceConfig ¶
type ServiceConfig struct {
// StartupHook is a hook that is called when service is started.
StartupHook StartupHook
// ShutdownHook is a hook that is called when service is stopped.
ShutdownHook ShutdownHook
// Name of the service.
Name string
// RestartPolicy is a restart policy for service.
RestartPolicy ServiceRestartPolicy
}
ServiceConfig represents lifecycle service configuration.
type ServiceRestartPolicy ¶
type ServiceRestartPolicy struct {
// RestartOnFailure indicates that service should be restarted on failure.
RestartOnFailure bool
// RestartDelay is a delay between restart attempts.
RestartDelay time.Duration
// RestartCount is a maximum number of restart attempts.
RestartCount int
}
ServiceRestartPolicy represents rules for service restart on runtime errors.
type ServiceStatus ¶
type ServiceStatus int
ServiceStatus represents current status of service.
const ( ServiceStatusInit ServiceStatus = iota ServiceStatusStarting ServiceStatusRunning ServiceStatusStopping ServiceStatusStopped ServiceStatusError )
All service statuses values.
func (ServiceStatus) String ¶
func (i ServiceStatus) String() string
type ShutdownHook ¶
ShutdownHook is a hook that is called when service is stopped. This hook is called with specified shutdown context.
type StartupHook ¶
StartupHook is a hook that is called when service is started. This hook is called with specified startup context. Error chanel is provided to report health status of service. If error is sent to error channel service could be restarted depends on configuration.