flow

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2017 License: Apache-2.0 Imports: 21 Imported by: 29

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterConnector

func RegisterConnector(name string, callback func(*ExchangeMessage, URI, ...interface{}) error)

RegisterConnector register a new Connector to use as From("my-connector://...")

Types

type Choice

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

Choice is the type for conditional structure of a Pipe

func NewChoice

func NewChoice(p *Flow) *Choice

NewChoice creates a new choice structure with a message

func (*Choice) Otherwise

func (c *Choice) Otherwise() *Choice

Otherwise is executed when others condiotions is not true - Like Else

func (*Choice) To

func (c *Choice) To(url string, params ...interface{}) *Choice

To execute a connector

func (*Choice) When

func (c *Choice) When(e HeaderFnc) *Choice

When is the conditional tester

type ExchangeMessage

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

ExchangeMessage is the message exchange inner Pipe

func NewExchangeMessage

func NewExchangeMessage() *ExchangeMessage

NewExchangeMessage creates new empty ExchangeMessage

func (*ExchangeMessage) BindJSON

func (e *ExchangeMessage) BindJSON(v interface{}) error

BindJSON binds json body to interface

func (*ExchangeMessage) BindXML

func (e *ExchangeMessage) BindXML(v interface{}) error

BindXML binds xml body to interface

func (*ExchangeMessage) ClearHeader

func (e *ExchangeMessage) ClearHeader()

ClearHeader removes all entries from header

func (*ExchangeMessage) DelHeader

func (e *ExchangeMessage) DelHeader(k string)

DelHeader delete header from message

func (*ExchangeMessage) GetBody

func (e *ExchangeMessage) GetBody() interface{}

GetBody return body from message

func (*ExchangeMessage) GetHeader

func (e *ExchangeMessage) GetHeader(k string) string

GetHeader returns a header value based on key

func (*ExchangeMessage) GetHeaderMap

func (e *ExchangeMessage) GetHeaderMap() HeaderMap

GetHeaderMap return the map from header

func (*ExchangeMessage) SetBody

func (e *ExchangeMessage) SetBody(b interface{})

SetBody writes the body to message

func (*ExchangeMessage) SetHeader

func (e *ExchangeMessage) SetHeader(k, v string)

SetHeader add a key-value header to a message

func (*ExchangeMessage) WriteJSON

func (e *ExchangeMessage) WriteJSON(v interface{}) error

WriteJSON marshall interface to JSON and set body

func (*ExchangeMessage) WriteXML

func (e *ExchangeMessage) WriteXML(v interface{}) error

WriteXML marshall interface to XML and set body

type Flow added in v0.3.0

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

Flow is the main data structure of Flow Pipe controls all the execution flow

func NewFlow added in v0.3.0

func NewFlow() *Flow

NewFlow creates a new empty Flow

func (*Flow) Choice added in v0.3.0

func (p *Flow) Choice() *Choice

Choice builds a choice block

func (*Flow) From added in v0.3.0

func (p *Flow) From(url string, params ...interface{}) *Flow

From is the entrypoint of a flow, all flows need to be started with From

func (*Flow) GetBody added in v0.3.0

func (p *Flow) GetBody() interface{}

GetBody from a message

func (*Flow) GetHeader added in v0.3.0

func (p *Flow) GetHeader() HeaderMap

GetHeader from a message

func (*Flow) SetBody added in v0.3.0

func (p *Flow) SetBody(b interface{}) *Flow

SetBody to a execution Flow

func (*Flow) SetHeader added in v0.3.0

func (p *Flow) SetHeader(k, v string) *Flow

SetHeader on message

func (*Flow) To added in v0.3.0

func (p *Flow) To(url string, params ...interface{}) *Flow

To is a method to create a flow based on connectors

type HeaderFnc

type HeaderFnc func(*Flow) (interface{}, *Flow)

HeaderFnc is a type to execute logical conditions from head values

func Header(s string) HeaderFnc

Header is the main entry point to execute logical conditions with header values

func (HeaderFnc) Exist

func (h HeaderFnc) Exist() HeaderFnc

Exist returns true if header[key] exist

func (HeaderFnc) IsEqualTo

func (h HeaderFnc) IsEqualTo(s string) HeaderFnc

IsEqualTo returns true if header[key] == s

type HeaderMap

type HeaderMap map[string]string

HeaderMap represent a key-value header pattern

func (HeaderMap) Add

func (h HeaderMap) Add(key, value string)

Add new entry to map

func (HeaderMap) Del

func (h HeaderMap) Del(key string)

Del entry from map

func (HeaderMap) Get

func (h HeaderMap) Get(key string) string

Get entry from map

func (HeaderMap) ListKeys

func (h HeaderMap) ListKeys() []string

ListKeys list keys from Map

type Message

type Message chan interface{}

Message is a channel to change message between pipes

type PipeProcessor

type PipeProcessor func(*ExchangeMessage, Message, func())

PipeProcessor is a function type to execute pipe workflow

type Stack

type Stack []interface{}

Stack for message channel

func (*Stack) Clear

func (s *Stack) Clear()

Clear stack

func (*Stack) Pop

func (s *Stack) Pop() interface{}

Pop a message from stack

func (*Stack) Push

func (s *Stack) Push(ext interface{})

Push a message to stack

func (Stack) Top

func (s Stack) Top() interface{}

Top return a message from top of stack

type Transform

type Transform string

Transform date from template to other

func (Transform) TransformFromJSON

func (original Transform) TransformFromJSON(from, to Transform, fncMap template.FuncMap) (string, error)

TransformFromJSON data from A to B

func (Transform) TransformFromXML

func (original Transform) TransformFromXML(from, to Transform, fncMap template.FuncMap) (string, error)

TransformFromXML data from A to B

type URI

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

URI is the pattern of connectors

func (URI) GetHost

func (u URI) GetHost() string

GetHost retruns connector host

func (URI) GetOption

func (u URI) GetOption(k string) string

GetOption from URI

func (URI) GetProtocol

func (u URI) GetProtocol() string

GetProtocol return connector schema

func (URI) GetRaw

func (u URI) GetRaw() string

GetRaw returns a plain text connector url

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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