Documentation ¶
Index ¶
- Constants
- Variables
- func Key(id string) datastore.Key
- func Walk(serviceID string, visitFn Visit, getService GetService, ...) error
- type DesiredState
- type FindChildService
- type GetChildServices
- type GetService
- type Service
- func (s *Service) AddVirtualHost(application, vhostName string) error
- func (s *Service) Equals(b *Service) bool
- func (service *Service) Evaluate(getSvc GetService, findChild FindChildService, instanceID int) (err error)
- func (service *Service) EvaluateActionsTemplate(gs GetService, fc FindChildService, instanceID int) (err error)
- func (service *Service) EvaluateConfigFilesTemplate(gs GetService, fc FindChildService, instanceID int) (err error)
- func (service *Service) EvaluateEndpointTemplates(gs GetService, fc FindChildService) (err error)
- func (service *Service) EvaluateHealthCheckTemplate(gs GetService, fc FindChildService, instanceID int) (err error)
- func (service *Service) EvaluateHostnameTemplate(gs GetService, fc FindChildService, instanceID int) (err error)
- func (service *Service) EvaluateLogConfigTemplate(gs GetService, fc FindChildService, instanceID int) (err error)
- func (service *Service) EvaluatePrereqsTemplate(gs GetService, fc FindChildService, instanceID int) (err error)
- func (service *Service) EvaluateRunsTemplate(gs GetService, fc FindChildService) (err error)
- func (service *Service) EvaluateStartupTemplate(gs GetService, fc FindChildService, instanceID int) (err error)
- func (service *Service) EvaluateVolumesTemplate(gs GetService, fc FindChildService, instanceID int) (err error)
- func (s Service) GetPath(gs GetService) (string, error)
- func (s *Service) GetServiceExports() []ServiceEndpoint
- func (s *Service) GetServiceImports() []ServiceEndpoint
- func (s *Service) GetServiceVHosts() []ServiceEndpoint
- func (s *Service) HasEndpointsFor(purpose string) bool
- func (s *Service) RemoveVirtualHost(application, vhostName string) error
- func (s *Service) ValidEntity() error
- type ServiceEndpoint
- type Store
- func (s *Store) Delete(ctx datastore.Context, id string) error
- func (s *Store) FindChildService(ctx datastore.Context, deploymentID, parentID, serviceName string) (*Service, error)
- func (s *Store) FindTenantByDeploymentID(ctx datastore.Context, deploymentID, name string) (*Service, error)
- func (s *Store) Get(ctx datastore.Context, id string) (*Service, error)
- func (s *Store) GetChildServices(ctx datastore.Context, parentID string) ([]Service, error)
- func (s *Store) GetServices(ctx datastore.Context) ([]Service, error)
- func (s *Store) GetServicesByDeployment(ctx datastore.Context, deploymentID string) ([]Service, error)
- func (s *Store) GetServicesByPool(ctx datastore.Context, poolID string) ([]Service, error)
- func (s *Store) GetTaggedServices(ctx datastore.Context, tags ...string) ([]Service, error)
- func (s *Store) GetUpdatedServices(ctx datastore.Context, since time.Duration) ([]Service, error)
- func (s *Store) Put(ctx datastore.Context, svc *Service) error
- type Visit
Constants ¶
const ( SVCRestart = DesiredState(-1) SVCStop = DesiredState(0) SVCRun = DesiredState(1) SVCPause = DesiredState(2) )
Variables ¶
var (
//MAPPING is the elastic mapping for a service
MAPPING, _ = elastic.NewMapping(mappingString)
)
Functions ¶
func Walk ¶
func Walk(serviceID string, visitFn Visit, getService GetService, getChildren GetChildServices) error
Walk traverses the service hierarchy and calls the supplied Visit function on each service
Types ¶
type DesiredState ¶
type DesiredState int
Desired states of services.
func (DesiredState) String ¶
func (state DesiredState) String() string
type FindChildService ¶
FindChildService finds a child service with a given name, error if not found
type GetChildServices ¶
GetChildServices returns a list of services that are children to the parentID, return empty list if none found
type GetService ¶
GetService return a service, return error if not found
type Service ¶
type Service struct { ID string Name string Title string // Title is a label used when describing this service in the context of a service tree Version string Context map[string]interface{} Startup string Description string Tags []string OriginalConfigs map[string]servicedefinition.ConfigFile ConfigFiles map[string]servicedefinition.ConfigFile Instances int InstanceLimits domain.MinMax ChangeOptions []string ImageID string PoolID string DesiredState int HostPolicy servicedefinition.HostPolicy Hostname string Privileged bool Launch string Endpoints []ServiceEndpoint Tasks []servicedefinition.Task ParentServiceID string Volumes []servicedefinition.Volume CreatedAt time.Time UpdatedAt time.Time DeploymentID string DisableImage bool LogConfigs []servicedefinition.LogConfig Snapshot servicedefinition.SnapshotCommands Runs map[string]string RAMCommitment utils.EngNotation CPUCommitment uint64 Actions map[string]string HealthChecks map[string]domain.HealthCheck // A health check for the service. Prereqs []domain.Prereq // Optional list of scripts that must be successfully run before kicking off the service command. MonitoringProfile domain.MonitorProfile MemoryLimit float64 PIDFile string datastore.VersionedEntity }
Service A Service that can run in serviced.
func BuildService ¶
func BuildService(sd servicedefinition.ServiceDefinition, parentServiceID string, poolID string, desiredState int, deploymentID string) (*Service, error)
BuildService build a service from a ServiceDefinition.
func (*Service) AddVirtualHost ¶
AddVirtualHost Add a virtual host for given service, this method avoids duplicates vhosts
func (*Service) Evaluate ¶
func (service *Service) Evaluate(getSvc GetService, findChild FindChildService, instanceID int) (err error)
Evaluate evaluates all the fields of the Service that we care about, using a runtimeContext with the current Service embedded, and adding instanceID as an extra attribute.
func (*Service) EvaluateActionsTemplate ¶
func (service *Service) EvaluateActionsTemplate(gs GetService, fc FindChildService, instanceID int) (err error)
EvaluateActionsTemplate parses and evaluates the Actions string of a service.
func (*Service) EvaluateConfigFilesTemplate ¶
func (service *Service) EvaluateConfigFilesTemplate(gs GetService, fc FindChildService, instanceID int) (err error)
EvaluateConfigFilesTemplate parses and evals the Filename and Content. This happens for each ConfigFile on the service.
func (*Service) EvaluateEndpointTemplates ¶
func (service *Service) EvaluateEndpointTemplates(gs GetService, fc FindChildService) (err error)
EvaluateEndpointTemplates parses and evaluates the "ApplicationTemplate" property of each of the service endpoints for this service.
func (*Service) EvaluateHealthCheckTemplate ¶
func (service *Service) EvaluateHealthCheckTemplate(gs GetService, fc FindChildService, instanceID int) (err error)
EvaluateHealthCheckTemplate parses and evals the Script field for each HealthCheck.
func (*Service) EvaluateHostnameTemplate ¶
func (service *Service) EvaluateHostnameTemplate(gs GetService, fc FindChildService, instanceID int) (err error)
EvaluateHostnameTemplate parses and evaluates the Hostname string of a service.
func (*Service) EvaluateLogConfigTemplate ¶
func (service *Service) EvaluateLogConfigTemplate(gs GetService, fc FindChildService, instanceID int) (err error)
EvaluateLogConfigTemplate parses and evals the Path, Type and all the values for the tags of the log configs. This happens for each LogConfig on the service.
func (*Service) EvaluatePrereqsTemplate ¶
func (service *Service) EvaluatePrereqsTemplate(gs GetService, fc FindChildService, instanceID int) (err error)
EvaluatePrereqsTemplate parses and evals the Script field for each Prereq.
func (*Service) EvaluateRunsTemplate ¶
func (service *Service) EvaluateRunsTemplate(gs GetService, fc FindChildService) (err error)
EvaluateRunsTemplate parses and evaluates the Runs string of a service.
func (*Service) EvaluateStartupTemplate ¶
func (service *Service) EvaluateStartupTemplate(gs GetService, fc FindChildService, instanceID int) (err error)
EvaluateStartupTemplate parses and evaluates the StartUp string of a service.
func (*Service) EvaluateVolumesTemplate ¶
func (service *Service) EvaluateVolumesTemplate(gs GetService, fc FindChildService, instanceID int) (err error)
EvaluateVolumesTemplate parses and evaluates the ResourcePath string in volumes of a service
func (Service) GetPath ¶
func (s Service) GetPath(gs GetService) (string, error)
GetPath uses the GetService function to determine the / delimited name path i.e. /test/app/sevicename
func (*Service) GetServiceExports ¶
func (s *Service) GetServiceExports() []ServiceEndpoint
GetServiceExports retrieves service endpoints whose purpose is "export"
func (*Service) GetServiceImports ¶
func (s *Service) GetServiceImports() []ServiceEndpoint
GetServiceImports retrieves service endpoints whose purpose is "import"
func (*Service) GetServiceVHosts ¶
func (s *Service) GetServiceVHosts() []ServiceEndpoint
GetServiceVHosts retrieves service endpoints that specify a virtual HostPort
func (*Service) HasEndpointsFor ¶
HasEndpointsFor determines if the service has any imports for the specified purpose, eg import
func (*Service) RemoveVirtualHost ¶
RemoveVirtualHost Remove a virtual host for given service
func (*Service) ValidEntity ¶
ValidEntity validate that Service has all required fields
type ServiceEndpoint ¶
type ServiceEndpoint struct { servicedefinition.EndpointDefinition AddressAssignment addressassignment.AddressAssignment }
ServiceEndpoint endpoint exported or imported by a service
func BuildServiceEndpoint ¶
func BuildServiceEndpoint(epd servicedefinition.EndpointDefinition) ServiceEndpoint
BuildServiceEndpoint build a ServiceEndpoint from a EndpointDefinition
func (*ServiceEndpoint) GetAssignment ¶
func (se *ServiceEndpoint) GetAssignment() *addressassignment.AddressAssignment
GetAssignment Returns nil if no assignment set
func (ServiceEndpoint) IsConfigurable ¶
func (endpoint ServiceEndpoint) IsConfigurable() bool
IsConfigurable returns true if the endpoint is configurable
func (*ServiceEndpoint) RemoveAssignment ¶
func (se *ServiceEndpoint) RemoveAssignment() error
RemoveAssignment resets a service endpoints to nothing
func (*ServiceEndpoint) SetAssignment ¶
func (se *ServiceEndpoint) SetAssignment(aa addressassignment.AddressAssignment) error
SetAssignment sets the AddressAssignment for the endpoint
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store type for interacting with Service persistent storage
func (*Store) FindChildService ¶
func (*Store) FindTenantByDeploymentID ¶
func (s *Store) FindTenantByDeploymentID(ctx datastore.Context, deploymentID, name string) (*Service, error)
FindTenantByDeployment returns the tenant service for a given deployment id and service name
func (*Store) GetChildServices ¶
GetChildServices returns services that are children of the given parent service id
func (*Store) GetServices ¶
GetServices returns all services
func (*Store) GetServicesByDeployment ¶
func (s *Store) GetServicesByDeployment(ctx datastore.Context, deploymentID string) ([]Service, error)
GetServicesByDeployment returns services with the given deployment id
func (*Store) GetServicesByPool ¶
GetServicesByPool returns services with the given pool id
func (*Store) GetTaggedServices ¶
GetTaggedServices returns services with the given tags
func (*Store) GetUpdatedServices ¶
GetUpdatedServices returns all services updated since "since" time.Duration ago