Documentation
¶
Index ¶
- Constants
- func Start(s *state.State, lanes [][]string) (*state.TaskSet, error)
- func Stop(s *state.State, lanes [][]string) (*state.TaskSet, error)
- func StopRunning(s *state.State, m *ServiceManager) (*state.TaskSet, error)
- type LogManager
- type Restarter
- type ServiceInfo
- type ServiceManager
- func (m *ServiceManager) CheckFailed(name string)
- func (m *ServiceManager) DefaultServiceNames() ([]string, error)
- func (m *ServiceManager) Ensure() error
- func (m *ServiceManager) PlanChanged(plan *plan.Plan)
- func (m *ServiceManager) Prune(pruneWait time.Duration, maxServiceData int)
- func (m *ServiceManager) Replan() ([][]string, [][]string, error)
- func (m *ServiceManager) SendSignal(services []string, signal string) error
- func (m *ServiceManager) ServiceLogs(services []string, last int) (map[string]servicelog.Iterator, error)
- func (m *ServiceManager) Services(names []string) ([]*ServiceInfo, error)
- func (m *ServiceManager) StartOrder(services []string) ([][]string, error)
- func (m *ServiceManager) StopOrder(services []string) ([][]string, error)
- func (m *ServiceManager) StopTimeout() time.Duration
- func (m *ServiceManager) WriteMetrics(writer metrics.Writer) error
- type ServiceRequest
- type ServiceStartup
- type ServiceStatus
Constants ¶
const ( StartupEnabled = "enabled" StartupDisabled = "disabled" )
Variables ¶
This section is empty.
Functions ¶
func StopRunning ¶
StopRunning creates and returns a task set for stopping all running services. It returns a nil *TaskSet if there are no services to stop.
Types ¶
type LogManager ¶
type LogManager interface {
ServiceStarted(service *plan.Service, logs *servicelog.RingBuffer)
}
type Restarter ¶
type Restarter interface {
HandleRestart(t restart.RestartType)
}
type ServiceInfo ¶
type ServiceInfo struct {
Name string
Startup ServiceStartup
Current ServiceStatus
CurrentSince time.Time
}
type ServiceManager ¶
type ServiceManager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(s *state.State, runner *state.TaskRunner, serviceOutput io.Writer, restarter Restarter, logMgr LogManager) (*ServiceManager, error)
func (*ServiceManager) CheckFailed ¶
func (m *ServiceManager) CheckFailed(name string)
CheckFailed response to a health check failure. If the given check name is in the on-check-failure map for a service, tell the service to perform the configured action (for example, "restart").
func (*ServiceManager) DefaultServiceNames ¶
func (m *ServiceManager) DefaultServiceNames() ([]string, error)
DefaultServiceNames returns the name of the services set to start by default.
func (*ServiceManager) Ensure ¶
func (m *ServiceManager) Ensure() error
Ensure implements StateManager.Ensure.
func (*ServiceManager) PlanChanged ¶ added in v1.10.0
func (m *ServiceManager) PlanChanged(plan *plan.Plan)
PlanChanged informs the service manager that the plan has been updated.
func (*ServiceManager) Prune ¶ added in v1.23.0
func (m *ServiceManager) Prune(pruneWait time.Duration, maxServiceData int)
Prune cleans up the in-memory serviceData:
- It removes the serviceData if a service is inactive and its currentSince is older than pruneWait.
- If the number of inactive serviceData entries is still more than maxServiceData, remove inactive services' serviceData even if they are not older than pruneWait. Inactive services are sorted by currentSince, and remove the older ones first.
func (*ServiceManager) Replan ¶
func (m *ServiceManager) Replan() ([][]string, [][]string, error)
Replan returns a list of services in lanes to stop and services to start because their plans had changed between when they started and this call.
func (*ServiceManager) SendSignal ¶
func (m *ServiceManager) SendSignal(services []string, signal string) error
func (*ServiceManager) ServiceLogs ¶
func (m *ServiceManager) ServiceLogs(services []string, last int) (map[string]servicelog.Iterator, error)
ServiceLogs returns iterators to the provided services. If last is negative, return tail iterators; if last is zero or positive, return head iterators going back last elements. Each iterator must be closed via the Close method.
func (*ServiceManager) Services ¶
func (m *ServiceManager) Services(names []string) ([]*ServiceInfo, error)
Services returns the list of configured services and their status, sorted by service name. Filter by the specified service names if provided.
func (*ServiceManager) StartOrder ¶
func (m *ServiceManager) StartOrder(services []string) ([][]string, error)
StartOrder returns the provided services, together with any required dependencies, in the proper order, put in lanes, for starting them all up.
func (*ServiceManager) StopOrder ¶
func (m *ServiceManager) StopOrder(services []string) ([][]string, error)
StopOrder returns the provided services, together with any dependants, in the proper order, put in lanes, for stopping them all.
func (*ServiceManager) StopTimeout ¶
func (m *ServiceManager) StopTimeout() time.Duration
StopTimeout returns the worst case duration that will have to be waited for to have all services in this manager stopped.
func (*ServiceManager) WriteMetrics ¶ added in v1.19.0
func (m *ServiceManager) WriteMetrics(writer metrics.Writer) error
WriteMetrics collects and writes metrics for all services to the provided writer.
type ServiceRequest ¶
type ServiceRequest struct {
Name string
}
ServiceRequest holds the details required to perform service tasks.
func TaskServiceRequest ¶
func TaskServiceRequest(task *state.Task) (*ServiceRequest, error)
TaskServiceRequest extracts the *ServiceRequest that was associated with the provided task when it was created, reflecting details of the operation requested.
type ServiceStartup ¶
type ServiceStartup string
type ServiceStatus ¶
type ServiceStatus string
const ( StatusActive ServiceStatus = "active" StatusBackoff ServiceStatus = "backoff" StatusError ServiceStatus = "error" StatusInactive ServiceStatus = "inactive" )