service

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

TODO(ilgooz): remove this file after service package made Newable.

Package service is a generated protocol buffer package.

It is generated from these files:

github.com/mesg-foundation/core/service/service.proto

It has these top-level messages:

Service
Event
Task
Output
Parameter
Dependency

Index

Constants

This section is empty.

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 {
	Image       string   `protobuf:"bytes,1,opt,name=image" json:"image,omitempty"`
	Volumes     []string `protobuf:"bytes,2,rep,name=volumes" json:"volumes,omitempty"`
	Volumesfrom []string `protobuf:"bytes,3,rep,name=volumesfrom" json:"volumesfrom,omitempty"`
	Ports       []string `protobuf:"bytes,4,rep,name=ports" json:"ports,omitempty"`
	Command     string   `protobuf:"bytes,5,opt,name=command" json:"command,omitempty"`
}

A dependency is a configuration of an other Docker container that runs separately from the service.

func (*Dependency) Descriptor

func (*Dependency) Descriptor() ([]byte, []int)

func (*Dependency) GetCommand

func (m *Dependency) GetCommand() string

func (*Dependency) GetImage

func (m *Dependency) GetImage() string

func (*Dependency) GetPorts

func (m *Dependency) GetPorts() []string

func (*Dependency) GetVolumes

func (m *Dependency) GetVolumes() []string

func (*Dependency) GetVolumesfrom

func (m *Dependency) GetVolumesfrom() []string

func (*Dependency) ProtoMessage

func (*Dependency) ProtoMessage()

func (*Dependency) Reset

func (m *Dependency) Reset()

func (*Dependency) String

func (m *Dependency) String() string

type DependencyFromService

type DependencyFromService struct {
	*Dependency
	Service *Service
	Name    string
}

DependencyFromService represents a Dependency with a pointer to its service and its name.

func (*DependencyFromService) Start

func (dependency *DependencyFromService) Start(networkID string) (containerServiceID string, err error)

Start starts a dependency container.

func (*DependencyFromService) Status

func (dependency *DependencyFromService) Status() (container.StatusType, error)

Status returns StatusType of dependency's container.

func (*DependencyFromService) Stop

func (dependency *DependencyFromService) Stop() error

Stop stops a dependency.

type Event

type Event struct {
	Name        string                `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
	Description string                `protobuf:"bytes,2,opt,name=description" json:"description,omitempty"`
	Data        map[string]*Parameter `` /* 128-byte string literal not displayed */
}

Events are emitted by the service whenever the service wants.

func (*Event) Descriptor

func (*Event) Descriptor() ([]byte, []int)

func (*Event) GetData

func (m *Event) GetData() map[string]*Parameter

func (*Event) GetDescription

func (m *Event) GetDescription() string

func (*Event) GetName

func (m *Event) GetName() string

func (*Event) IsValid added in v0.2.0

func (e *Event) IsValid(data map[string]interface{}) bool

IsValid returns true if the data are valid for a specific event.

func (*Event) ProtoMessage

func (*Event) ProtoMessage()

func (*Event) Reset

func (m *Event) Reset()

func (*Event) String

func (m *Event) String() string

func (*Event) Validate added in v0.2.0

func (e *Event) Validate(data map[string]interface{}) []*ParameterWarning

Validate data for a specific event

type EventNotFoundError added in v0.2.0

type EventNotFoundError struct {
	Service  *Service
	EventKey string
}

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

func (*EventNotFoundError) Error added in v0.2.0

func (e *EventNotFoundError) Error() string

type InputNotFoundError added in v0.2.0

type InputNotFoundError struct {
	Service  *Service
	TaskKey  string
	InputKey string
}

InputNotFoundError is an error when a service doesn't contains a specific input.

func (*InputNotFoundError) Error added in v0.2.0

func (e *InputNotFoundError) Error() string

type InvalidEventDataError added in v0.2.0

type InvalidEventDataError struct {
	Event     *Event
	EventKey  string
	EventData map[string]interface{}
}

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

func (*InvalidEventDataError) Error added in v0.2.0

func (e *InvalidEventDataError) Error() string

type InvalidOutputDataError added in v0.2.0

type InvalidOutputDataError struct {
	Output     *Output
	TaskKey    string
	OutputKey  string
	OutputData map[string]interface{}
}

InvalidOutputDataError is an error when the outputs for one task result are not valid.

func (*InvalidOutputDataError) Error added in v0.2.0

func (e *InvalidOutputDataError) Error() string

type InvalidTaskInputError added in v0.2.0

type InvalidTaskInputError struct {
	Task      *Task
	TaskKey   string
	InputData map[string]interface{}
}

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

func (*InvalidTaskInputError) Error added in v0.2.0

func (e *InvalidTaskInputError) Error() string

type Output

type Output struct {
	Name        string                `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
	Description string                `protobuf:"bytes,2,opt,name=description" json:"description,omitempty"`
	Data        map[string]*Parameter `` /* 128-byte string literal not displayed */
}

A output is the data a task must return.

func (*Output) Descriptor

func (*Output) Descriptor() ([]byte, []int)

func (*Output) GetData

func (m *Output) GetData() map[string]*Parameter

func (*Output) GetDescription

func (m *Output) GetDescription() string

func (*Output) GetName

func (m *Output) GetName() string

func (*Output) IsValid added in v0.2.0

func (o *Output) IsValid(data map[string]interface{}) bool

IsValid returns true if the data are valid for a specific output.

func (*Output) ProtoMessage

func (*Output) ProtoMessage()

func (*Output) Reset

func (m *Output) Reset()

func (*Output) String

func (m *Output) String() string

func (*Output) Validate added in v0.2.0

func (o *Output) Validate(data map[string]interface{}) []*ParameterWarning

Validate data for a specific output.

type OutputNotFoundError added in v0.2.0

type OutputNotFoundError struct {
	Service   *Service
	TaskKey   string
	OutputKey string
}

OutputNotFoundError is an error when a service doesn't contain a specific output.

func (*OutputNotFoundError) Error added in v0.2.0

func (e *OutputNotFoundError) Error() string

type Parameter

type Parameter struct {
	Name        string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
	Description string `protobuf:"bytes,2,opt,name=description" json:"description,omitempty"`
	Type        string `protobuf:"bytes,3,opt,name=type" json:"type,omitempty"`
	Optional    bool   `protobuf:"varint,4,opt,name=optional" json:"optional,omitempty"`
}

A parameter is the definition of a specific value.

func (*Parameter) Descriptor

func (*Parameter) Descriptor() ([]byte, []int)

func (*Parameter) GetDescription

func (m *Parameter) GetDescription() string

func (*Parameter) GetName

func (m *Parameter) GetName() string

func (*Parameter) GetOptional

func (m *Parameter) GetOptional() bool

func (*Parameter) GetType

func (m *Parameter) GetType() string

func (*Parameter) ProtoMessage

func (*Parameter) ProtoMessage()

func (*Parameter) Reset

func (m *Parameter) Reset()

func (*Parameter) String

func (m *Parameter) String() string

func (*Parameter) Validate added in v0.2.0

func (p *Parameter) Validate(data interface{}) *ParameterWarning

Validate returns a warning based on the match of the data given in parameter and the parameter.

type ParameterWarning added in v0.2.0

type ParameterWarning struct {
	// contains filtered or unexported fields
}

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 {
	Name          string                 `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
	Description   string                 `protobuf:"bytes,2,opt,name=description" json:"description,omitempty"`
	Tasks         map[string]*Task       `` /* 130-byte string literal not displayed */
	Events        map[string]*Event      `` /* 132-byte string literal not displayed */
	Dependencies  map[string]*Dependency `` /* 144-byte string literal not displayed */
	Configuration *Dependency            `protobuf:"bytes,8,opt,name=configuration" json:"configuration,omitempty"`
	Repository    string                 `protobuf:"bytes,9,opt,name=repository" json:"repository,omitempty"`
}

This is the definition of a MESG Service.

func (*Service) Cast added in v0.2.0

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

Cast converts map[string]string to map[string]interface{} based on defined types in the service tasks map.

func (*Service) DependenciesFromService

func (s *Service) DependenciesFromService() []*DependencyFromService

DependenciesFromService returns a slice of DependencyFromService.

func (*Service) Descriptor

func (*Service) Descriptor() ([]byte, []int)

func (*Service) EventSubscriptionChannel

func (service *Service) EventSubscriptionChannel() string

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

func (*Service) GetConfiguration

func (m *Service) GetConfiguration() *Dependency

func (*Service) GetDependencies

func (m *Service) GetDependencies() map[string]*Dependency

func (*Service) GetDescription

func (m *Service) GetDescription() string

func (*Service) GetEvents

func (m *Service) GetEvents() map[string]*Event

func (*Service) GetName

func (m *Service) GetName() string

func (*Service) GetRepository

func (m *Service) GetRepository() string

func (*Service) GetTasks

func (m *Service) GetTasks() map[string]*Task

func (*Service) Hash

func (service *Service) Hash() string

Hash calculates and returns the hash of the service.

func (*Service) Logs

func (service *Service) Logs(onlyForDependency string) ([]io.ReadCloser, error)

Logs returns the service's docker service logs. Optionally only shows the logs of a given dependency.

func (*Service) ProtoMessage

func (*Service) ProtoMessage()

func (*Service) Reset

func (m *Service) Reset()

func (*Service) ResultSubscriptionChannel

func (service *Service) ResultSubscriptionChannel() string

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

func (*Service) Start

func (service *Service) Start() (serviceIDs []string, err error)

Start starts the service.

func (*Service) Status

func (service *Service) Status() (StatusType, error)

Status returns StatusType of all dependency.

func (*Service) Stop

func (service *Service) Stop() error

Stop stops a service.

func (*Service) StopDependencies

func (service *Service) StopDependencies() error

StopDependencies stops all dependencies.

func (*Service) String

func (m *Service) String() string

func (*Service) TaskSubscriptionChannel

func (service *Service) TaskSubscriptionChannel() string

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

type StatusType

type StatusType uint

StatusType of the service.

const (
	STOPPED StatusType = 0
	PARTIAL StatusType = 1
	RUNNING StatusType = 2
)

Possible statuses for service.

type Task

type Task struct {
	Name        string                `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
	Description string                `protobuf:"bytes,2,opt,name=description" json:"description,omitempty"`
	Inputs      map[string]*Parameter `` /* 132-byte string literal not displayed */
	Outputs     map[string]*Output    `` /* 134-byte string literal not displayed */
}

A task is a function that requires inputs and returns output.

func (*Task) Descriptor

func (*Task) Descriptor() ([]byte, []int)

func (*Task) GetDescription

func (m *Task) GetDescription() string

func (*Task) GetInputs

func (m *Task) GetInputs() map[string]*Parameter

func (*Task) GetName

func (m *Task) GetName() string

func (*Task) GetOutputs

func (m *Task) GetOutputs() map[string]*Output

func (*Task) IsValid added in v0.2.0

func (t *Task) IsValid(data map[string]interface{}) bool

IsValid returns true if the inputs are valid for a specific task.

func (*Task) ProtoMessage

func (*Task) ProtoMessage()

func (*Task) Reset

func (m *Task) Reset()

func (*Task) String

func (m *Task) String() string

func (*Task) Validate added in v0.2.0

func (t *Task) Validate(data map[string]interface{}) []*ParameterWarning

Validate inputs for a specific task.

type TaskNotFoundError added in v0.2.0

type TaskNotFoundError struct {
	Service *Service
	TaskKey string
}

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

func (*TaskNotFoundError) Error added in v0.2.0

func (e *TaskNotFoundError) Error() string

Directories

Path Synopsis
assets
Code generated by go-bindata.
Code generated by go-bindata.

Jump to

Keyboard shortcuts

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