Documentation ¶
Index ¶
- func CountServices(sgs []ServiceOrGroup) int
- func DoForServices(sgs []ServiceOrGroup, task tracker.Task, ...) error
- func RegisterBackend(loader BackendLoader)
- func RegisterLegacyMarshaler(l LegacyMarshaler)
- type Backend
- type BackendConfig
- type BackendLoader
- type BackendStatus
- type Builder
- type ContextOverride
- type LegacyMarshaler
- type OperationConfig
- type Runner
- type ServiceConfig
- func (c *ServiceConfig) Backend() Backend
- func (c *ServiceConfig) GetDescription() string
- func (c *ServiceConfig) GetName() string
- func (c *ServiceConfig) GetPid(pidFile string) (int, error)
- func (c *ServiceConfig) GetPidPathLegacy(pidDir string) string
- func (c *ServiceConfig) GetRunLog(logDir string) string
- func (c *ServiceConfig) GetStateBase(stateDir string) string
- func (c *ServiceConfig) GetStatePath(stateDir string) string
- func (c *ServiceConfig) IdentifyingFilename() string
- func (c *ServiceConfig) IdentifyingFilenameWithEncoding(encoding *base64.Encoding) string
- func (c *ServiceConfig) IsSudo(cfg OperationConfig) bool
- func (c *ServiceConfig) Matches(name string) bool
- func (c *ServiceConfig) MatchesPlatform() bool
- func (c *ServiceConfig) SetWatch(watch ServiceWatch) error
- func (c *ServiceConfig) UnmarshalJSON(data []byte) error
- func (c *ServiceConfig) Watch() ([]ServiceWatch, error)
- type ServiceGroupConfig
- func (c *ServiceGroupConfig) Children() []ServiceOrGroup
- func (c *ServiceGroupConfig) GetDescription() string
- func (c *ServiceGroupConfig) GetName() string
- func (c *ServiceGroupConfig) IsSudo(cfg OperationConfig) bool
- func (c *ServiceGroupConfig) Matches(name string) bool
- func (c *ServiceGroupConfig) Watch() ([]ServiceWatch, error)
- type ServiceOrGroup
- type ServiceWatch
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountServices ¶
func CountServices(sgs []ServiceOrGroup) int
CountServices returns the total number of services in the slice of services and groups.
func DoForServices ¶ added in v1.8.8
func DoForServices(sgs []ServiceOrGroup, task tracker.Task, f func(service *ServiceConfig, overrides ContextOverride, task tracker.Task) error) error
DoForServices performs a taks for a set of services
func RegisterBackend ¶ added in v1.8.9
func RegisterBackend(loader BackendLoader)
func RegisterLegacyMarshaler ¶ added in v1.8.9
func RegisterLegacyMarshaler(l LegacyMarshaler)
Types ¶
type BackendConfig ¶ added in v1.8.9
type BackendConfig struct { Name string `json:"name"` Type string `json:"type"` Config Backend `json:"-"` }
BackendConfig provides backend configuration for json
func (*BackendConfig) MarshalJSON ¶ added in v1.8.9
func (c *BackendConfig) MarshalJSON() ([]byte, error)
func (*BackendConfig) UnmarshalJSON ¶ added in v1.8.9
func (c *BackendConfig) UnmarshalJSON(data []byte) error
type BackendLoader ¶ added in v1.8.9
type BackendStatus ¶ added in v1.8.9
type BackendStatus struct { Ports []string MemoryInfo *process.MemoryInfoStat }
type Builder ¶ added in v1.8.9
func GetBuilder ¶ added in v1.8.9
func GetBuilder(cfg OperationConfig, s *ServiceConfig) (Builder, error)
type ContextOverride ¶
type ContextOverride struct { // Overrides to environment variables Env []string }
ContextOverride defines overrides for service configuration caused by commandline flags or group configuration.
func (ContextOverride) Merge ¶
func (c ContextOverride) Merge(m ContextOverride) ContextOverride
type LegacyMarshaler ¶ added in v1.8.9
type LegacyMarshaler interface {
Unmarshal([]byte, *ServiceConfig) error
}
type OperationConfig ¶
type OperationConfig struct { WorkingDir string EdwardExecutable string // Path to the edward executable for launching runners Exclusions []string // Names of services/groups to be excluded from this operation NoWatch bool SkipBuild bool Tags []string // Tags to pass to `edward run` LogFile string Backends map[string]string // Service overrides for backends }
OperationConfig provides additional configuration for an operation on a service or group
func (*OperationConfig) IsExcluded ¶
func (o *OperationConfig) IsExcluded(sg ServiceOrGroup) bool
IsExcluded returns true if the given service/group is excluded by this OperationConfig. No operations should be performed on excluded services.
type Runner ¶ added in v1.8.9
type Runner interface { Start(standardLog io.Writer, errorLog io.Writer) error Stop(workingDir string, getenv func(string) string) ([]byte, error) Status() (BackendStatus, error) Wait() }
func GetRunner ¶ added in v1.8.9
func GetRunner(cfg OperationConfig, s *ServiceConfig) (Runner, error)
type ServiceConfig ¶
type ServiceConfig struct { // Service name, used to identify in commands Name string `json:"name"` // Alternative names for this service Aliases []string `json:"aliases,omitempty"` // Service description Description string `json:"description,omitempty"` // Optional path to service. If nil, uses cwd Path *string `json:"path,omitempty"` // Does this service require sudo privileges? RequiresSudo bool `json:"requiresSudo,omitempty"` // Env holds environment variables for a service, for example: GOPATH=~/gocode/ // These will be added to the vars in the environment under which the Edward command was run Env []string `json:"env,omitempty"` Platform string `json:"platform,omitempty"` // Path to watch for updates, relative to config file. If specified, will enable hot reloading. WatchJSON json.RawMessage `json:"watch,omitempty"` // Action for warming up this service Warmup *warmup.Warmup `json:"warmup,omitempty"` // Path to config file from which this service was loaded // This may be the file that imported the config containing the service definition. ConfigFile string `json:"-"` Backends []*BackendConfig `json:"backends"` }
ServiceConfig represents a service that can be managed by Edward
func Services ¶ added in v1.8.8
func Services(sgs []ServiceOrGroup) []*ServiceConfig
Services returns a slice of services from a slice of services or groups.
func (*ServiceConfig) Backend ¶ added in v1.8.9
func (c *ServiceConfig) Backend() Backend
Backend returns the default backend for this service
func (*ServiceConfig) GetDescription ¶
func (c *ServiceConfig) GetDescription() string
GetDescription returns the description for this service
func (*ServiceConfig) GetName ¶
func (c *ServiceConfig) GetName() string
GetName returns the name for this service
func (*ServiceConfig) GetPid ¶ added in v1.8.8
func (c *ServiceConfig) GetPid(pidFile string) (int, error)
func (*ServiceConfig) GetPidPathLegacy ¶
func (c *ServiceConfig) GetPidPathLegacy(pidDir string) string
func (*ServiceConfig) GetRunLog ¶
func (c *ServiceConfig) GetRunLog(logDir string) string
GetRunLog returns the path to the run log for this service
func (*ServiceConfig) GetStateBase ¶ added in v1.8.8
func (c *ServiceConfig) GetStateBase(stateDir string) string
func (*ServiceConfig) GetStatePath ¶ added in v1.8.8
func (c *ServiceConfig) GetStatePath(stateDir string) string
func (*ServiceConfig) IdentifyingFilename ¶ added in v1.8.8
func (c *ServiceConfig) IdentifyingFilename() string
IdentifyingFilename returns a filename that can be used to identify this service uniquely among all services that may be configured on a machine. The filename will be based on the service name and the path to its Edward config. It does not include an extension.
func (*ServiceConfig) IdentifyingFilenameWithEncoding ¶ added in v1.8.9
func (c *ServiceConfig) IdentifyingFilenameWithEncoding(encoding *base64.Encoding) string
IdentifyingFilenameWithEncoding is equivalent to IdentifyingFilenameWithEncoding
func (*ServiceConfig) IsSudo ¶
func (c *ServiceConfig) IsSudo(cfg OperationConfig) bool
IsSudo returns true if this service requires sudo to run. If this service is excluded by cfg, then will always return false.
func (*ServiceConfig) Matches ¶
func (c *ServiceConfig) Matches(name string) bool
Matches returns true if the service name or an alias matches the provided name.
func (*ServiceConfig) MatchesPlatform ¶
func (c *ServiceConfig) MatchesPlatform() bool
MatchesPlatform determines whether or not this service can be run on the current OS
func (*ServiceConfig) SetWatch ¶
func (c *ServiceConfig) SetWatch(watch ServiceWatch) error
SetWatch sets the watch configuration for this service
func (*ServiceConfig) UnmarshalJSON ¶
func (c *ServiceConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON provides additional handling when unmarshaling a service from config. Currently, this handles legacy fields and fields with multiple possible types.
func (*ServiceConfig) Watch ¶
func (c *ServiceConfig) Watch() ([]ServiceWatch, error)
Watch returns the watch configuration for this service
type ServiceGroupConfig ¶
type ServiceGroupConfig struct { // A name for this group, used to identify it in commands Name string // Alternative names for this group Aliases []string // A description Description string // Full services contained within this group Services []*ServiceConfig // Groups on which this group depends Groups []*ServiceGroupConfig // Launch order for children ChildOrder []string // Environment variables to be passed to all child services Env []string }
ServiceGroupConfig is a group of services that can be managed together
func (*ServiceGroupConfig) Children ¶ added in v1.8.8
func (c *ServiceGroupConfig) Children() []ServiceOrGroup
Children returns a slice of all children of this group in the configured order
func (*ServiceGroupConfig) GetDescription ¶
func (c *ServiceGroupConfig) GetDescription() string
GetDescription returns the description for this group
func (*ServiceGroupConfig) GetName ¶
func (c *ServiceGroupConfig) GetName() string
GetName returns the name for this group
func (*ServiceGroupConfig) IsSudo ¶
func (c *ServiceGroupConfig) IsSudo(cfg OperationConfig) bool
IsSudo returns true if any of the services in this group require sudo to run
func (*ServiceGroupConfig) Matches ¶
func (c *ServiceGroupConfig) Matches(name string) bool
Matches returns true if the group name or an alias matches the provided name.
func (*ServiceGroupConfig) Watch ¶
func (c *ServiceGroupConfig) Watch() ([]ServiceWatch, error)
Watch returns all service watches configured for this group
type ServiceOrGroup ¶
type ServiceOrGroup interface { GetName() string GetDescription() string IsSudo(cfg OperationConfig) bool Watch() ([]ServiceWatch, error) }
ServiceOrGroup provides a common interface to services and groups
type ServiceWatch ¶
type ServiceWatch struct { Service *ServiceConfig `json:"-"` IncludedPaths []string `json:"include,omitempty"` ExcludedPaths []string `json:"exclude,omitempty"` }
ServiceWatch defines a set of directories to be watched for changes to a service's source.