Documentation
¶
Index ¶
- func CommandString(base, extra []string) string
- type Check
- type CheckLevel
- type ContextOptions
- type ExecCheck
- type FormatError
- type HTTPCheck
- type Layer
- type LogTarget
- type LogTargetType
- type OptionalDuration
- type OptionalFloat
- type Override
- type Plan
- type Service
- type ServiceAction
- type ServiceStartup
- type TCPCheck
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommandString ¶
CommandString returns a service command as a string after appending the arguments in "extra" to the command in "base"
Types ¶
type Check ¶
type Check struct {
// Basic details
Name string `yaml:"-"`
Override Override `yaml:"override,omitempty"`
Level CheckLevel `yaml:"level,omitempty"`
// Common check settings
Period OptionalDuration `yaml:"period,omitempty"`
Timeout OptionalDuration `yaml:"timeout,omitempty"`
Threshold int `yaml:"threshold,omitempty"`
// Type-specific check settings (only one of these can be set)
HTTP *HTTPCheck `yaml:"http,omitempty"`
TCP *TCPCheck `yaml:"tcp,omitempty"`
Exec *ExecCheck `yaml:"exec,omitempty"`
}
Check specifies configuration for a single health check.
type CheckLevel ¶
type CheckLevel string
CheckLevel specifies the optional check level.
const ( UnsetLevel CheckLevel = "" AliveLevel CheckLevel = "alive" ReadyLevel CheckLevel = "ready" )
type ContextOptions ¶
type ContextOptions struct {
Environment map[string]string
UserID *int
User string
GroupID *int
Group string
WorkingDir string
}
ContextOptions holds service context config fields.
func MergeServiceContext ¶
func MergeServiceContext(p *Plan, serviceName string, overrides ContextOptions) (ContextOptions, error)
MergeServiceContext merges the overrides on top of the service context specified by serviceName, returning a new ContextOptions value. If serviceName is "" (context not specified), return overrides directly.
type ExecCheck ¶
type ExecCheck struct {
Command string `yaml:"command,omitempty"`
ServiceContext string `yaml:"service-context,omitempty"`
Environment map[string]string `yaml:"environment,omitempty"`
UserID *int `yaml:"user-id,omitempty"`
User string `yaml:"user,omitempty"`
GroupID *int `yaml:"group-id,omitempty"`
Group string `yaml:"group,omitempty"`
WorkingDir string `yaml:"working-dir,omitempty"`
}
ExecCheck holds the configuration for an exec health check.
type FormatError ¶
type FormatError struct {
Message string
}
FormatError is the error returned when a layer has a format error, such as a missing "override" field.
func (*FormatError) Error ¶
func (e *FormatError) Error() string
type HTTPCheck ¶
type HTTPCheck struct {
URL string `yaml:"url,omitempty"`
Headers map[string]string `yaml:"headers,omitempty"`
}
HTTPCheck holds the configuration for an HTTP health check.
type Layer ¶
type Layer struct {
Order int `yaml:"-"`
Label string `yaml:"-"`
Summary string `yaml:"summary,omitempty"`
Description string `yaml:"description,omitempty"`
Services map[string]*Service `yaml:"services,omitempty"`
Checks map[string]*Check `yaml:"checks,omitempty"`
LogTargets map[string]*LogTarget `yaml:"log-targets,omitempty"`
}
func CombineLayers ¶
CombineLayers combines the given layers into a single layer, with the later layers overriding earlier ones.
func ReadLayersDir ¶
type LogTarget ¶
type LogTarget struct {
Name string `yaml:"-"`
Type LogTargetType `yaml:"type"`
Location string `yaml:"location"`
Services []string `yaml:"services"`
Override Override `yaml:"override,omitempty"`
}
LogTarget specifies a remote server to forward logs to.
type LogTargetType ¶
type LogTargetType string
LogTargetType defines the protocol to use to forward logs.
const ( LokiTarget LogTargetType = "loki" SyslogTarget LogTargetType = "syslog" UnsetLogTarget LogTargetType = "" )
type OptionalDuration ¶
func (OptionalDuration) IsZero ¶
func (o OptionalDuration) IsZero() bool
func (OptionalDuration) MarshalYAML ¶
func (o OptionalDuration) MarshalYAML() (interface{}, error)
func (*OptionalDuration) UnmarshalYAML ¶
func (o *OptionalDuration) UnmarshalYAML(value *yaml.Node) error
type OptionalFloat ¶
func (OptionalFloat) IsZero ¶
func (o OptionalFloat) IsZero() bool
func (OptionalFloat) MarshalYAML ¶
func (o OptionalFloat) MarshalYAML() (interface{}, error)
func (*OptionalFloat) UnmarshalYAML ¶
func (o *OptionalFloat) UnmarshalYAML(value *yaml.Node) error
type Plan ¶
type Plan struct {
Layers []*Layer `yaml:"-"`
Services map[string]*Service `yaml:"services,omitempty"`
Checks map[string]*Check `yaml:"checks,omitempty"`
LogTargets map[string]*LogTarget `yaml:"log-targets,omitempty"`
}
func ReadDir ¶
ReadDir reads the configuration layers from the "layers" sub-directory in dir, and returns the resulting Plan. If the "layers" sub-directory doesn't exist, it returns a valid Plan with no layers.
func (*Plan) StartOrder ¶
StartOrder returns the required services that must be started for the named services to be properly started, in the order that they must be started. An error is returned when a provided service name does not exist, or there is an order cycle involving the provided service or its dependencies.
func (*Plan) StopOrder ¶
StopOrder returns the required services that must be stopped for the named services to be properly stopped, in the order that they must be stopped. An error is returned when a provided service name does not exist, or there is an order cycle involving the provided service or its dependencies.
type Service ¶
type Service struct {
// Basic details
Name string `yaml:"-"`
Summary string `yaml:"summary,omitempty"`
Description string `yaml:"description,omitempty"`
Startup ServiceStartup `yaml:"startup,omitempty"`
Override Override `yaml:"override,omitempty"`
Command string `yaml:"command,omitempty"`
// Service dependencies
After []string `yaml:"after,omitempty"`
Before []string `yaml:"before,omitempty"`
Requires []string `yaml:"requires,omitempty"`
// Options for command execution
Environment map[string]string `yaml:"environment,omitempty"`
UserID *int `yaml:"user-id,omitempty"`
User string `yaml:"user,omitempty"`
GroupID *int `yaml:"group-id,omitempty"`
Group string `yaml:"group,omitempty"`
WorkingDir string `yaml:"working-dir,omitempty"`
// Auto-restart and backoff functionality
OnSuccess ServiceAction `yaml:"on-success,omitempty"`
OnFailure ServiceAction `yaml:"on-failure,omitempty"`
OnCheckFailure map[string]ServiceAction `yaml:"on-check-failure,omitempty"`
BackoffDelay OptionalDuration `yaml:"backoff-delay,omitempty"`
BackoffFactor OptionalFloat `yaml:"backoff-factor,omitempty"`
BackoffLimit OptionalDuration `yaml:"backoff-limit,omitempty"`
KillDelay OptionalDuration `yaml:"kill-delay,omitempty"`
}
func (*Service) ParseCommand ¶
ParseCommand returns a service command as two stream of strings. The base command is returned as a stream and the default arguments in [ ... ] group is returned as another stream.
type ServiceAction ¶
type ServiceAction string
const ( ActionUnset ServiceAction = "" ActionRestart ServiceAction = "restart" ActionShutdown ServiceAction = "shutdown" ActionIgnore ServiceAction = "ignore" )
type ServiceStartup ¶
type ServiceStartup string
const ( StartupUnknown ServiceStartup = "" StartupEnabled ServiceStartup = "enabled" StartupDisabled ServiceStartup = "disabled" )