service

package
v0.0.0-...-88aa921 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2015 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SVCRestart = DesiredState(-1)
	SVCStop    = DesiredState(0)
	SVCRun     = DesiredState(1)
	SVCPause   = DesiredState(2)
)

Variables

View Source
var (

	//MAPPING is the elastic mapping for a service
	MAPPING, _ = elastic.NewMapping(mappingString)
)

Functions

func Key

func Key(id string) datastore.Key

Key creates a Key suitable for getting, putting and deleting Services

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

type FindChildService func(parentID, childName string) (Service, error)

FindChildService finds a child service with a given name, error if not found

type GetChildServices

type GetChildServices func(parentID string) ([]Service, error)

GetChildServices returns a list of services that are children to the parentID, return empty list if none found

type GetService

type GetService func(serviceID string) (Service, error)

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
	CPUShares         int64
	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 NewService

func NewService() (s *Service, err error)

NewService Create a new Service.

func (*Service) AddVirtualHost

func (s *Service) AddVirtualHost(application, vhostName string) error

AddVirtualHost Add a virtual host for given service, this method avoids duplicates vhosts

func (*Service) Equals

func (s *Service) Equals(b *Service) bool

Equals are they the same

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

func (s *Service) HasEndpointsFor(purpose string) bool

HasEndpointsFor determines if the service has any imports for the specified purpose, eg import

func (*Service) RemoveVirtualHost

func (s *Service) RemoveVirtualHost(application, vhostName string) error

RemoveVirtualHost Remove a virtual host for given service

func (*Service) ValidEntity

func (s *Service) ValidEntity() error

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

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

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 NewStore

func NewStore() *Store

NewStore creates a Service store

func (*Store) Delete

func (s *Store) Delete(ctx datastore.Context, id string) error

Delete removes the a Service if it exists

func (*Store) FindChildService

func (s *Store) FindChildService(ctx datastore.Context, deploymentID, parentID, serviceName string) (*Service, error)

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) Get

func (s *Store) Get(ctx datastore.Context, id string) (*Service, error)

Get a Service by id. Return ErrNoSuchEntity if not found

func (*Store) GetChildServices

func (s *Store) GetChildServices(ctx datastore.Context, parentID string) ([]Service, error)

GetChildServices returns services that are children of the given parent service id

func (*Store) GetServices

func (s *Store) GetServices(ctx datastore.Context) ([]Service, error)

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

func (s *Store) GetServicesByPool(ctx datastore.Context, poolID string) ([]Service, error)

GetServicesByPool returns services with the given pool id

func (*Store) GetTaggedServices

func (s *Store) GetTaggedServices(ctx datastore.Context, tags ...string) ([]Service, error)

GetTaggedServices returns services with the given tags

func (*Store) GetUpdatedServices

func (s *Store) GetUpdatedServices(ctx datastore.Context, since time.Duration) ([]Service, error)

GetUpdatedServices returns all services updated since "since" time.Duration ago

func (*Store) Put

func (s *Store) Put(ctx datastore.Context, svc *Service) error

Put adds or updates a Service

type Visit

type Visit func(svc *Service) error

Visit called with current Service being visited

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL