service

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

MainServiceKey is key for main service.

Variables

This section is empty.

Functions

func ListRunning

func ListRunning() ([]string, error)

ListRunning returns all the running services.2 TODO: should move to another file

Types

type Dependency

type Dependency struct {
	// Key is the key of dependency.
	Key string `hash:"1"`

	// Image is the Docker image.
	Image string `hash:"name:2"`

	// Volumes are the Docker volumes.
	Volumes []string `hash:"name:3"`

	// VolumesFrom are the docker volumes-from from.
	VolumesFrom []string `hash:"name:4"`

	// Ports holds ports configuration for container.
	Ports []string `hash:"name:5"`

	// Command is the Docker command which will be executed when container started.
	Command string `hash:"name:6"`

	// Argument holds the args to pass to the Docker container
	Args []string `hash:"name:7"`

	// Env is a slice of environment variables in key=value format.
	Env []string `hash:"name:8"`
}

Dependency represents a Docker container and it holds instructions about how it should run.

type ErrNotDefinedEnv added in v0.6.0

type ErrNotDefinedEnv struct {
	Env []string
}

ErrNotDefinedEnv error returned when optionally given env variables are not defined in the mesg.yml file.

func (ErrNotDefinedEnv) Error added in v0.6.0

func (e ErrNotDefinedEnv) Error() string

type Event

type Event struct {
	// Key is the key of event.
	Key string `hash:"name:1"`

	// Name is the name of event.
	Name string `hash:"name:2"`

	// Description is the description of event.
	Description string `hash:"name:3"`

	// Data holds the input parameters of event.
	Data []*Parameter `hash:"name:4"`
	// contains filtered or unexported fields
}

Event describes a service task.

func (*Event) RequireData added in v0.3.0

func (e *Event) RequireData(eventData map[string]interface{}) error

RequireData requires event datas to be matched with parameter schemas.

func (*Event) ValidateData added in v0.3.0

func (e *Event) ValidateData(eventData map[string]interface{}) []*ParameterWarning

ValidateData produces warnings for event datas that doesn't satisfy their parameter schemas.

type EventNotFoundError added in v0.2.0

type EventNotFoundError struct {
	EventKey    string
	ServiceName string
}

EventNotFoundError is an error returned when corresponding event cannot be found in service.

func (*EventNotFoundError) Error added in v0.2.0

func (e *EventNotFoundError) Error() string

type InvalidEventDataError added in v0.2.0

type InvalidEventDataError struct {
	EventKey    string
	ServiceName string
	Warnings    []*ParameterWarning
}

InvalidEventDataError is an error returned when the data of corresponding event is not valid.

func (*InvalidEventDataError) Error added in v0.2.0

func (e *InvalidEventDataError) Error() string

type InvalidTaskInputError added in v0.2.0

type InvalidTaskInputError struct {
	TaskKey     string
	ServiceName string
	Warnings    []*ParameterWarning
}

InvalidTaskInputError is an error returned when the inputs of corresponding task are not valid.

func (*InvalidTaskInputError) Error added in v0.2.0

func (e *InvalidTaskInputError) Error() string

type InvalidTaskOutputError added in v0.3.0

type InvalidTaskOutputError struct {
	TaskKey       string
	TaskOutputKey string
	ServiceName   string
	Warnings      []*ParameterWarning
}

InvalidTaskOutputError is an error returned when the outputs of corresponding task are not valid.

func (*InvalidTaskOutputError) Error added in v0.3.0

func (e *InvalidTaskOutputError) Error() string

type Log added in v0.3.0

type Log struct {
	Dependency string
	Standard   io.ReadCloser
	Error      io.ReadCloser
}

Log holds log streams of dependency.

type Output

type Output struct {
	// Key is the key of output.
	Key string `hash:"name:1"`

	// Name is the name of task output.
	Name string `hash:"name:2"`

	// Description is the description of task output.
	Description string `hash:"name:3"`

	// Data holds the output parameters of a task output.
	Data []*Parameter `hash:"name:4"`
	// contains filtered or unexported fields
}

Output describes task output.

func (*Output) RequireData added in v0.3.0

func (o *Output) RequireData(outputData map[string]interface{}) error

RequireData requires task outputs to be matched with parameter schemas.

func (*Output) ValidateData added in v0.3.0

func (o *Output) ValidateData(outputData map[string]interface{}) []*ParameterWarning

ValidateData produces warnings for task outputs that doesn't satisfy their parameter schemas.

type Parameter

type Parameter struct {
	// Key is the key of parameter.
	Key string `hash:"name:1"`

	// Name is the name of parameter.
	Name string `hash:"name:2"`

	// Description is the description of parameter.
	Description string `hash:"name:3"`

	// Type is the data type of parameter.
	Type string `hash:"name:4"`

	// Optional indicates if parameter is optional.
	Optional bool `hash:"name:5"`

	// Repeated is to have an array of this parameter
	Repeated bool `hash:"name:6"`

	// Definition of the structure of the object when the type is object
	Object []*Parameter `hash:"name:7"`
}

Parameter describes task input parameters, output parameters of a task output and input parameters of an event.

type ParameterWarning added in v0.2.0

type ParameterWarning struct {
	Key       string
	Warning   string
	Parameter *Parameter
}

ParameterWarning contains a specific warning related to a parameter.

func (*ParameterWarning) String added in v0.2.0

func (p *ParameterWarning) String() string

type Service

type Service struct {
	// Hash is calculated from the combination of service's source and mesg.yml.
	// It represents the service uniquely.
	Hash string `hash:"-"`

	// Sid is the service id.
	// It needs to be unique and can be used to access to service.
	Sid string `hash:"name:1"`

	// Name is the service name.
	Name string `hash:"name:2"`

	// Description is service description.
	Description string `hash:"name:3"`

	// Tasks are the list of tasks that service can execute.
	Tasks []*Task `hash:"name:4"`

	// Events are the list of events that service can emit.
	Events []*Event `hash:"name:5"`

	// Dependencies are the Docker containers that service can depend on.
	Dependencies []*Dependency `hash:"name:6"`

	// Configuration of the service
	Configuration *Dependency `hash:"name:8"`

	// Repository holds the service's repository url if it's living on
	// a Git host.
	Repository string `hash:"name:7"`

	// DeployedAt holds the creation time of service.
	DeployedAt time.Time `hash:"-"`
}

Service represents a MESG service.

func (*Service) DeleteVolumes added in v0.5.0

func (s *Service) DeleteVolumes(c container.Container) error

DeleteVolumes deletes the data volumes of service and its dependencies.

func (*Service) EventSubscriptionChannel

func (service *Service) EventSubscriptionChannel() string

EventSubscriptionChannel returns the channel to listen for events from this service.

func (*Service) GetEvent added in v0.3.0

func (s *Service) GetEvent(eventKey string) (*Event, error)

GetEvent returns event eventKey of service.

func (*Service) GetTask added in v0.3.0

func (s *Service) GetTask(taskKey string) (*Task, error)

GetTask returns task taskKey of service.

func (*Service) Logs

func (s *Service) Logs(c container.Container, dependencies ...string) ([]*Log, error)

Logs gives service's logs streams. when dependencies filter is not provided, it'll give logs for all dependencies otherwise it'll only give logs for specified dependencies. note that, service itself is also a dependency defined with special "service" key. in order to get service's own logs, "service" key must be included to dependencies filter.

func (*Service) ResultSubscriptionChannel

func (service *Service) ResultSubscriptionChannel() string

ResultSubscriptionChannel returns the channel to listen for tasks from this service.

func (*Service) Start

func (s *Service) Start(c container.Container) (serviceIDs []string, err error)

Start starts the service.

func (*Service) Status

func (s *Service) Status(c container.Container) (StatusType, error)

Status returns StatusType of all dependency.

func (*Service) Stop

func (s *Service) Stop(c container.Container) error

Stop stops a service.

func (*Service) TaskSubscriptionChannel

func (service *Service) TaskSubscriptionChannel() string

TaskSubscriptionChannel returns the channel to listen for tasks from this service.

func (*Service) ValidateConfigurationEnv added in v0.9.0

func (s *Service) ValidateConfigurationEnv(env map[string]string) error

ValidateConfigurationEnv checks presence of env variables in mesg.yml under env section.

type StatusType

type StatusType uint

StatusType of the service.

const (
	UNKNOWN StatusType = iota
	STOPPED
	STARTING
	PARTIAL
	RUNNING
)

Possible statuses for service.

func (StatusType) String added in v0.3.0

func (s StatusType) String() string

type Task

type Task struct {
	// Key is the key of task.
	Key string `hash:"name:1"`

	// Name is the name of task.
	Name string `hash:"name:2"`

	// Description is the description of task.
	Description string `hash:"name:3"`

	// Inputs are the definition of the execution inputs of task.
	Inputs []*Parameter `hash:"name:4"`

	// Outputs are the definition of the execution results of task.
	Outputs []*Output `hash:"name:5"`
	// contains filtered or unexported fields
}

Task describes a service task.

func (*Task) GetOutput added in v0.3.0

func (t *Task) GetOutput(outputKey string) (*Output, error)

GetOutput returns output outputKey of task.

func (*Task) RequireInputs added in v0.3.0

func (t *Task) RequireInputs(taskInputs map[string]interface{}) error

RequireInputs requires task inputs to be matched with parameter schemas.

func (*Task) ValidateInputs added in v0.3.0

func (t *Task) ValidateInputs(taskInputs map[string]interface{}) []*ParameterWarning

ValidateInputs produces warnings for task inputs that doesn't satisfy their parameter schemas.

type TaskNotFoundError added in v0.2.0

type TaskNotFoundError struct {
	TaskKey     string
	ServiceName string
}

TaskNotFoundError is an error returned when corresponding task cannot be found in service.

func (*TaskNotFoundError) Error added in v0.2.0

func (e *TaskNotFoundError) Error() string

type TaskOutputNotFoundError added in v0.3.0

type TaskOutputNotFoundError struct {
	TaskKey       string
	TaskOutputKey string
	ServiceName   string
}

TaskOutputNotFoundError is an error returned when service doesn't contain corresponding output.

func (*TaskOutputNotFoundError) Error added in v0.3.0

func (e *TaskOutputNotFoundError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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