servicedefinition

package
Version: v0.0.0-...-45f56e5 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: Apache-2.0 Imports: 15 Imported by: 11

Documentation

Index

Constants

View Source
const (
	// DEFAULT policy for scheduling a service instance
	DEFAULT HostPolicy = ""
	// LeastCommitted run on host w/ least committed resources
	LeastCommitted = "LEAST_COMMITTED"
	// Balance is a synonym for LeastCommitted
	Balance = "balance"
	// Pack runs instance on eligible host with most committed resources
	Pack = "pack"
	// PreferSeparate attempt to schedule instances of a service on separate hosts
	PreferSeparate = "PREFER_SEPARATE"
	// RequireSeparate schedule instances of a service on separate hosts
	RequireSeparate = "REQUIRE_SEPARATE"
)
View Source
const (
	// DefaultChangeOption is the default change option (none).
	DefaultChangeOption = ChangeOption("")

	// RestartAllOnInstanceChanged option restarts all instances when the instance count changes.
	// If the number of running instances doesn't match the requested number of instances in the service
	// definition, all instances will be restarted.  Note that this can happen due to an instance going down
	// or by the service def being modified.
	RestartAllOnInstanceChanged = ChangeOption("restartAllOnInstanceChanged")

	// RestartAllOnInstanceZeroDown option will stop and restart all running instances if there is no instance 0.
	// If the running instances doesn't contain instance 0, all services will be shut down so that when they come
	// back up we'll get a new instance 0.
	RestartAllOnInstanceZeroDown = ChangeOption("restartAllOnInstanceZeroDown")
)

Variables

View Source
var (
	ErrNoServiceJson = errors.New("directory does not contain a service.json file")
)

Functions

func GetConfigFileType

func GetConfigFileType() string

GetConfigFileType returns the ConfigFiles type

func GetType

func GetType() string

GetType return the ServiceDefinition's type It returns the type as a string

func Walk

func Walk(sd *ServiceDefinition, visit Visit) error

Walk a ServiceDefinition hierarchy and call the Visit function at each ServiceDefinition. Returns error if any Visit returns an error

Types

type AddressResourceConfig

type AddressResourceConfig struct {
	Port     uint16
	Protocol string
}

AddressResourceConfig defines an external facing port for a service definition

func (*AddressResourceConfig) Normalize

func (arc *AddressResourceConfig) Normalize()

Normalize adjusts attributes to be in an expected format, lowercases and trims certain fields

func (AddressResourceConfig) ValidEntity

func (arc AddressResourceConfig) ValidEntity() error

ValidEntity used to make sure AddressResourceConfig is in a valid state

type AddressResourceConfigByPort

type AddressResourceConfigByPort []AddressResourceConfig

AddressResourceConfigByPort implements sort.Interface for []AddressResourceConfig based on the Port field

func (AddressResourceConfigByPort) Len

func (AddressResourceConfigByPort) Less

func (a AddressResourceConfigByPort) Less(i, j int) bool

func (AddressResourceConfigByPort) Swap

func (a AddressResourceConfigByPort) Swap(i, j int)

type ChangeOption

type ChangeOption string

ChangeOption is the policy for what happens in the scheduler Sync when the running services change

func (*ChangeOption) UnmarshalText

func (co *ChangeOption) UnmarshalText(b []byte) error

UnmarshalText implements the encoding/TextUnmarshaler interface

type ChangeOptions

type ChangeOptions []ChangeOption

ChangeOptions is a list of ChangeOption objects.

func (ChangeOptions) Contains

func (options ChangeOptions) Contains(co ChangeOption) bool

Contains returns true if the ChangeOptions object contains the ChangeOption object.

type ConfigFile

type ConfigFile struct {
	Filename    string // complete path of file
	Owner       string // owner of file within the container, root:root or 0:0 for root owned file, what you would pass to chown
	Permissions string // permission of file, eg 0664, what you would pass to chmod
	Content     string // content of config file
}

ConfigFile config file for a service

type EndpointDefinition

type EndpointDefinition struct {
	Name                string // Human readable name of the endpoint. Unique per service definition
	Purpose             string
	Protocol            string
	PortNumber          uint16
	PortTemplate        string // A template which, if specified, is used to calculate the port number
	VirtualAddress      string // An address by which an imported endpoint may be accessed within the container, e.g. "mysqlhost:1234"
	Application         string
	ApplicationTemplate string
	AddressConfig       AddressResourceConfig

	// VHost is used to request named vhost for this endpoint. Should be the name of a
	// subdomain, i.e "myapplication"  not "myapplication.host.com"
	VHosts []string

	VHostList []VHost // VHost is used to request named vhost(s) for this endpoint.
	PortList  []Port
}

EndpointDefinition An endpoint that a Service exposes.

func (*EndpointDefinition) UnmarshalJSON

func (e *EndpointDefinition) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the encoding/json/Unmarshaler interface used to convert deprecated vhosts list to VHostList

func (EndpointDefinition) ValidEntity

func (se EndpointDefinition) ValidEntity() error

ValidEntity used to make sure ServiceEndpoint is in a valid state

type HostPolicy

type HostPolicy string

HostPolicy represents the optional policy used to determine which hosts on which to run instances of a service. Default is to run on the available host with the most uncommitted RAM.

func (*HostPolicy) UnmarshalText

func (p *HostPolicy) UnmarshalText(b []byte) error

UnmarshalText implements the encoding/TextUnmarshaler interface

type LogConfig

type LogConfig struct {
	Path    string   // The location on the container's filesystem of the log, can be a directory
	Type    string   // Arbitrary string that identifies the "types" of logs that come from this source. This will be
	Filters []string // A list of filters that must be contained in either the LogFilters or a parent's LogFilter,
	LogTags []LogTag // Key value pair of tags that are sent to logstash for all entries coming out of this logfile
	IsAudit bool     // Whether to send log entries to /var/log/serviced/application-audit.log or not for each LogConfig Type
}

LogConfig represents the configuration for a logfile for a service.

type LogTag

type LogTag struct {
	Name  string
	Value string
}

LogTag no clue what this is. Maybe someone actually reads this

type Port

type Port struct {
	PortAddr string // which port number to use for this endpoint
	Enabled  bool   // whether the port should be enabled or disabled.
	UseTLS   bool   // Does this port endpoint use tls.
	Protocol string // What protocol (if any) does the endpoind use.
}

Port is the configuration for an application endpoint port.

type ServiceDefinition

type ServiceDefinition struct {
	Name        string // Name of the defined service
	Title       string // Title is a label used when describing this service in the context of a service tree
	Version     string // Version of the defined service
	Command     string // Command which runs the service
	RunAs       string // Run command as user
	Description string // Description of the service

	Environment []string // Environment variables to be injected, of the form NAME="value"
	Tags        []string // Searchable service tags

	ImageID       string         // Docker image hosting the service
	Instances     domain.MinMax  // Constraints on the number of instances
	ChangeOptions []ChangeOption // Control options for what happens when a running service is changed
	Launch        string         // Must be "AUTO", the default, or "MANUAL"
	HostPolicy    HostPolicy     // Policy for starting up instances
	Hostname      string         // Optional hostname which should be set on run
	Privileged    bool           // Whether to run the container with extended privileges

	ConfigFiles map[string]ConfigFile  // Config file templates
	Context     map[string]interface{} // Context information for the service
	Endpoints   []EndpointDefinition   // Comms endpoints used by the service
	Services    []ServiceDefinition    // Supporting subservices
	LogFilters  map[string]string      // map of log filter name to log filter definitions

	Volumes    []Volume // list of volumes to bind into containers
	LogConfigs []LogConfig

	Snapshot      SnapshotCommands  // Snapshot quiesce info for the service: Pause/Resume bash commands
	RAMCommitment utils.EngNotation // expected RAM commitment to use for scheduling
	RAMThreshold  uint              // RAM Threshold
	CPUCommitment uint64            // expected CPU commitment (#cores) to use for scheduling
	DisableShell  bool              // disables shell commands on the service

	Runs         map[string]string             // FIXME: This field is deprecated. Remove when possible.
	Commands     map[string]domain.Command     // Map of commands that can be executed with 'serviced run ...'
	Actions      map[string]string             // Map of commands that can be executed with 'serviced action ...'
	HealthChecks map[string]health.HealthCheck // HealthChecks for a service.

	// Prereqs is a list of scripts that must run successfully before running the command in the Startup field.
	Prereqs []domain.Prereq

	MonitoringProfile domain.MonitorProfile // An optional list of queryable metrics, graphs, and thresholds
	MemoryLimit       float64
	CPUShares         int64
	OomKillDisable    bool  // Whether to disable OOM Killer for the container or not
	OomScoreAdj       int64 // Tune containers OOM preferences (-1000 to 1000)

	PIDFile string // An optional path or command to generate a path for a PID file to which signals are relayed.

	StartLevel uint // Services start in the order implied by this field (low to high) and stopped in reverse order

	EmergencyShutdownLevel uint // Services are stopped in this order during an emergency (low to high).
}

ServiceDefinition is the definition of a node in a service hierarchy.

func BuildFromPath

func BuildFromPath(path string) (*ServiceDefinition, error)

BuildFromPath given a path will create a ServiceDefintion

func (*ServiceDefinition) GetID

func (s *ServiceDefinition) GetID() string

GetID return a ServiceDefinition instance's ID It returns the ID as a string

func (*ServiceDefinition) GetType

func (s *ServiceDefinition) GetType() string

GetType returns the ServiceDefinition instance's type It returns the type as a string

func (*ServiceDefinition) NormalizeLaunch

func (sd *ServiceDefinition) NormalizeLaunch()

NormalizeLaunch normalizes the launch string. Sets to commons.AUTO if empty otherwise just trims and lower cases. Does not check if value is valid

func (ServiceDefinition) String

func (s ServiceDefinition) String() string

func (*ServiceDefinition) UnmarshalJSON

func (s *ServiceDefinition) UnmarshalJSON(b []byte) error

UnmarshalJSON loads a JSON byte stream into the ServiceDefinition object.

func (*ServiceDefinition) ValidEntity

func (sd *ServiceDefinition) ValidEntity() error

ValidEntity validates Host fields

type ServiceDefinitionByName

type ServiceDefinitionByName []ServiceDefinition

ServiceDefinitionByName implements sort.Interface for []ServiceDefinition based on Name field

func (ServiceDefinitionByName) Len

func (a ServiceDefinitionByName) Len() int

func (ServiceDefinitionByName) Less

func (a ServiceDefinitionByName) Less(i, j int) bool

func (ServiceDefinitionByName) Swap

func (a ServiceDefinitionByName) Swap(i, j int)

type SnapshotCommands

type SnapshotCommands struct {
	Pause  string // bash command to pause the volume  (quiesce)
	Resume string // bash command to resume the volume (unquiesce)
}

SnapshotCommands commands to be called during and after a snapshot

type VHost

type VHost struct {
	Name    string // name of the vhost subdomain subdomain, i.e "myapplication"  not "myapplication.host.com
	Enabled bool   // whether the vhost should be enabled or disabled.
}

VHost is the configuration for an application endpoint that wants an http VHost endpoint provided by Control Center

type Visit

type Visit func(sd *ServiceDefinition) error

Visit function called when walking a ServiceDefinition hierarchy

type Volume

type Volume struct {
	Owner              string // Resource Path Owner
	Permission         string // Resource Path permissions, eg what you pass to chmod
	ResourcePath       string // Resource Pool Path, shared across all hosts in a resource pool
	ContainerPath      string // Container bind-mount path
	Type               string // Path use, i.e. "dfs" or "tmp"
	InitContainerPath  string // Path to initialize the volume from at creation time, optional
	ExcludeFromBackups bool   // Whether to exclude this volume from backups
}

Volume import defines a file system directory underneath an export directory

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL