Documentation ¶
Index ¶
- Constants
- type Configuration
- type Dependency
- type Event
- type EventNotFoundError
- type InvalidEventDataError
- type InvalidTaskInputError
- type InvalidTaskOutputError
- type Parameter
- type ParameterWarning
- type Service
- func (s *Service) GetDependency(dependencyKey string) (*Dependency, error)
- func (s *Service) GetEvent(eventKey string) (*Event, error)
- func (s *Service) GetTask(taskKey string) (*Task, error)
- func (s *Service) RequireEventData(eventKey string, eventData map[string]interface{}) error
- func (s *Service) RequireTaskInputs(taskKey string, taskInputs map[string]interface{}) error
- func (s *Service) RequireTaskOutputs(taskKey string, taskOutputs map[string]interface{}) error
- func (s *Service) ValidateEventData(eventKey string, eventData map[string]interface{}) ([]*ParameterWarning, error)
- func (s *Service) ValidateTaskInputs(taskKey string, taskInputs map[string]interface{}) ([]*ParameterWarning, error)
- func (s *Service) ValidateTaskOutputs(taskKey string, taskOutputs map[string]interface{}) ([]*ParameterWarning, error)
- type StatusType
- type Task
- type TaskNotFoundError
Constants ¶
const MainServiceKey = "service"
MainServiceKey is key for main service.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Configuration ¶ added in v0.13.0
type Configuration struct { // Volumes are the Docker volumes. Volumes []string `hash:"name:1" validate:"unique,dive,printascii"` // VolumesFrom are the docker volumes-from from. VolumesFrom []string `hash:"name:2" validate:"unique,dive,printascii"` // Ports holds ports configuration for container. Ports []string `hash:"name:3" validate:"unique,dive,portmap"` // Command is the Docker command which will be executed when container started. Command string `hash:"name:4" validate:"printascii"` // Argument holds the args to pass to the Docker container Args []string `hash:"name:5" validate:"dive,printascii"` // Env is a slice of environment variables in key=value format. Env []string `hash:"name:6" validate:"unique,dive,env"` }
Configuration represents the main Docker container and it holds instructions about how it should run. Similar to Dependency.
type Dependency ¶
type Dependency struct { *Configuration // Key is the key of dependency. Key string `hash:"name:1" validate:"printascii"` // Image is the Docker image. Image string `hash:"name:2" validate:"printascii"` }
Dependency represents a Docker container and it holds instructions about how it should run.
type Event ¶
type Event struct { // Key is the key of event. Key string `hash:"name:1" validate:"printascii"` // Name is the name of event. Name string `hash:"name:2" validate:"printascii"` // Description is the description of event. Description string `hash:"name:3" validate:"printascii"` // Data holds the input parameters of event. Data []*Parameter `hash:"name:4" validate:"dive,required"` }
Event describes a service task.
type EventNotFoundError ¶ added in v0.2.0
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 Parameter ¶
type Parameter struct { // Key is the key of parameter. Key string `hash:"name:1" validate:"printascii"` // Name is the name of parameter. Name string `hash:"name:2" validate:"printascii"` // Description is the description of parameter. Description string `hash:"name:3" validate:"printascii"` // Type is the data type of parameter. Type string `hash:"name:4" validate:"required,printascii,oneof=String Number Boolean Object Any"` // 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" validate:"unique,dive,required"` }
Parameter describes task input parameters, output parameters of a task output and input parameters of an event.
type ParameterWarning ¶ added in v0.2.0
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 hash.Hash `hash:"-" validate:"required"` // Sid is the service id. // It needs to be unique and can be used to access to service. Sid string `hash:"name:1" validate:"required,printascii,max=63,domain"` // Name is the service name. Name string `hash:"name:2" validate:"required,printascii"` // Description is service description. Description string `hash:"name:3" validate:"printascii"` // Tasks are the list of tasks that service can execute. Tasks []*Task `hash:"name:4" validate:"dive,required"` // Events are the list of events that service can emit. Events []*Event `hash:"name:5" validate:"dive,required"` // Dependencies are the Docker containers that service can depend on. Dependencies []*Dependency `hash:"name:6" validate:"dive,required"` // Configuration of the service Configuration *Configuration `hash:"name:8" validate:"required"` // Repository holds the service's repository url if it's living on // a Git host. Repository string `hash:"name:7" validate:"omitempty,uri"` // Source is the hash id of service's source code on IPFS. Source string `hash:"name:9" validate:"required,printascii"` }
Service represents a MESG service.
func (*Service) GetDependency ¶ added in v0.11.0
func (s *Service) GetDependency(dependencyKey string) (*Dependency, error)
GetDependency returns dependency dependencyKey or a not found error.
func (*Service) RequireEventData ¶ added in v0.11.0
RequireEventData requires event datas to be matched with parameter schemas.
func (*Service) RequireTaskInputs ¶ added in v0.11.0
RequireTaskInputs requires task inputs to match with parameter schemas.
func (*Service) RequireTaskOutputs ¶ added in v0.11.0
RequireTaskOutputs requires task outputs to match with parameter schemas.
func (*Service) ValidateEventData ¶ added in v0.11.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.11.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.11.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" validate:"printascii"` // Name is the name of task. Name string `hash:"name:2" validate:"printascii"` // Description is the description of task. Description string `hash:"name:3" validate:"printascii"` // Inputs are the definition of the execution inputs of task. Inputs []*Parameter `hash:"name:4" validate:"dive,required"` // Outputs are the definition of the execution results of task. Outputs []*Parameter `hash:"name:5" validate:"dive,required"` }
Task describes a service task.
type TaskNotFoundError ¶ added in v0.2.0
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