service

package
v0.10.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

MainServiceKey is key for main service.

Variables

This section is empty.

Functions

This section is empty.

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"`
}

Event describes a service task.

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
	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 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"`

	// Source is the hash id of service's source code on IPFS.
	Source string `hash:"name:9"`

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

Service represents a MESG service.

func (*Service) GetDependency added in v0.10.0

func (s *Service) GetDependency(dependencyKey string) (*Dependency, error)

GetDependency returns dependency dependencyKey or a not found error.

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) RequireEventData added in v0.10.0

func (s *Service) RequireEventData(eventKey string, eventData map[string]interface{}) error

RequireEventData requires event datas to be matched with parameter schemas.

func (*Service) RequireTaskInputs added in v0.10.0

func (s *Service) RequireTaskInputs(taskKey string, taskInputs map[string]interface{}) error

RequireTaskInputs requires task inputs to match with parameter schemas.

func (*Service) RequireTaskOutputs added in v0.10.0

func (s *Service) RequireTaskOutputs(taskKey string, taskOutputs map[string]interface{}) error

RequireTaskOutputs requires task outputs to match with parameter schemas.

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.

func (*Service) ValidateEventData added in v0.10.0

func (s *Service) ValidateEventData(eventKey string, eventData map[string]interface{}) ([]*ParameterWarning, error)

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

func (*Service) ValidateTaskInputs added in v0.10.0

func (s *Service) ValidateTaskInputs(taskKey string, taskInputs map[string]interface{}) ([]*ParameterWarning, error)

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

func (*Service) ValidateTaskOutputs added in v0.10.0

func (s *Service) ValidateTaskOutputs(taskKey string, taskOutputs map[string]interface{}) ([]*ParameterWarning, error)

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

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 []*Parameter `hash:"name:5"`
}

Task describes a service task.

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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