mesg

package module
v0.0.0-...-d780f4f Latest Latest
Warning

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

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

README

go-application GoDoc

Documentation

Overview

Package mesg is an application client for mesg-core. For more information please visit https://mesg.com.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

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

Application represents is a MESG application.

func New

func New(options ...Option) (*Application, error)

New returns a new Application with options.

func (*Application) Close

func (a *Application) Close() error

Close gracefully waits current events or results to complete their process and and closes underlying connections.

func (*Application) WhenEvent

func (a *Application) WhenEvent(serviceID string, conditions ...EventCondition) *EventEmitter

WhenEvent creates an EventEmitter for serviceID.

func (*Application) WhenResult

func (a *Application) WhenResult(serviceID string, conditions ...ResultCondition) *ResultEmitter

WhenResult creates a ResultEmitter for serviceID.

type Data

type Data interface{}

Data is piped as the input data to task.

type Dialer

type Dialer interface {
	Dial() (net.Conn, error)
}

Dialer describes a dialer implementation for network.

type Event

type Event struct {
	Key string
	// contains filtered or unexported fields
}

Event represents an event.

func (*Event) Data

func (e *Event) Data(out interface{}) error

Data decodes event data into out.

type EventCondition

type EventCondition func(*EventEmitter)

EventCondition is the condition configurator for filtering events.

func EventKeyCondition

func EventKeyCondition(event string) EventCondition

EventKeyCondition returns a new condition to filter events by name. Default is all(*).

type EventEmitter

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

EventEmitter is a MESG event emitter.

func (*EventEmitter) Execute

func (e *EventEmitter) Execute(serviceID, taskKey string) (*Listener, error)

Execute starts for listening events and executes task taskKey for serviceID with the output data of event or return value of Map if all Filter funcs returned as true.

func (*EventEmitter) Filter

func (e *EventEmitter) Filter(fn func(*Event) (execute bool)) *EventEmitter

Filter sets filter funcs that will be executed to decide to execute the task or not. It's possible to add multiple filters by calling Filter multiple times. Other filter funcs and the task execution will no proceed if a filter func returns false.

func (*EventEmitter) Map

func (e *EventEmitter) Map(fn func(*Event) Data) Executor

Map sets the returned data as the input data of task. You can dynamically produce input values for task over event data.

type Executor

type Executor interface {
	Execute(serviceID, task string) (*Listener, error)
}

Executor is a task executor for emitters.

type Listener

type Listener struct {
	// Err filled when Listener fails to continue.
	Err chan error
	// contains filtered or unexported fields
}

Listener is a task execution listener.

func (*Listener) Close

func (l *Listener) Close() error

Close gracefully waits current events or results to complete their process and stops listening for future events or results.

type Option

type Option func(*Application)

Option is the configuration func of Application.

func DialOption

func DialOption(dialer Dialer) Option

DialOption used to mock socket communication for unit testing.

func EndpointOption

func EndpointOption(address string) Option

EndpointOption receives the endpoint of MESG.

func LogOutputOption

func LogOutputOption(out io.Writer) Option

LogOutputOption uses out as a log destination.

type Result

type Result struct {
	TaskKey   string
	OutputKey string
	Tags      []string
	// contains filtered or unexported fields
}

Result represents a task result.

func (*Result) Data

func (e *Result) Data(out interface{}) error

Data decodes result data into out.

type ResultCondition

type ResultCondition func(*ResultEmitter)

ResultCondition is the condition configurator for filtering results.

func OutputKeyCondition

func OutputKeyCondition(outputKey string) ResultCondition

OutputKeyCondition returns a new option to filter results by outputKey. Default is all(*).

func TagsCondition

func TagsCondition(executionTags ...string) ResultCondition

TagsCondition returns a new option to filter results by executionTags. This is a "match all" algorithm. All tags should be included in the execution to have a match.

func TaskKeyCondition

func TaskKeyCondition(taskKey string) ResultCondition

TaskKeyCondition returns a new option to filter results by taskKey. Default is all(*).

type ResultEmitter

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

ResultEmitter is a MESG result event listener.

func (*ResultEmitter) Execute

func (e *ResultEmitter) Execute(serviceID, taskKey string) (*Listener, error)

Execute starts for listening events and executes task taskKey for serviceID with the output data of result or return value of Map if all Filter funcs returned as true.

func (*ResultEmitter) Filter

func (e *ResultEmitter) Filter(fn func(*Result) (execute bool)) *ResultEmitter

Filter sets filter funcs that will be executed to decide to execute the task or not. It's possible to add multiple filters by calling Filter multiple times. Other filter funcs and the task execution will no proceed if a filter func returns false.

func (*ResultEmitter) Map

func (e *ResultEmitter) Map(fn func(*Result) Data) Executor

Map sets the returned data as the input data of task. You can dynamically produce input values for task over result data.

Directories

Path Synopsis
examples
quickstart/cmd
Package main is a quick-start application.
Package main is a quick-start application.
Package mesgtest is a testing package for MESG application.
Package mesgtest is a testing package for MESG application.

Jump to

Keyboard shortcuts

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