flux

package module
v0.0.0-...-761941a Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2015 License: MIT Imports: 21 Imported by: 2

README

Flux

GoDoc Travis

A library of interesting structs for the adventurous

#License

. MIT License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrInvalidMinWorkers defines an error when the minimum worker provided is below or at 0
	ErrInvalidMinWorkers = errors.New("Invalid minimum worker value")
	//ErrInvalidMaxWorkers is returned when the max worker value is incorrect
	ErrInvalidMaxWorkers = errors.New("Invalid maximum worker value")
	//ErrInvalidAddRequest is returned when the pool has reached its maximum worker value and cant add anymore
	ErrInvalidAddRequest = errors.New("Pool is at maximum worker efficiency")
	//ErrWorkRequestDenied is returned when the pool is unable to service a task
	ErrWorkRequestDenied = errors.New("Pool unable to accept task")
)
View Source
var (
	//ErrBadState stands for a struct in a bad state
	ErrBadState = errors.New("")
)
View Source
var ErrBufferEmpty = errors.New("Buffer: Is Empty")

ErrBufferEmpty is returned when a op is performed with an empty buffer

View Source
var ErrEmptyStack = errors.New("Stack Empty")

ErrEmptyStack is returned when a stack is empty

View Source
var ErrFailedBind = errors.New("Failed to Bind Reactors")

ErrFailedBind represent a failure in binding two Reactors

View Source
var ErrQueueEmpty = errors.New("Queue: Is Empty")

ErrQueueEmpty is returned when the queue has no more elements

View Source
var ErrReactorClosed = errors.New("Reactor is Closed")

ErrReactorClosed returned when reactor is closed

View Source
var ErrValueType = errors.New("Value is not a string type")

ErrValueType is returned by FileLoader if it gets a type that is not a string

Functions

func Backwards

func Backwards(to int, fx func(int))

Backwards takes a value and walks Backward till 0

func BackwardsIf

func BackwardsIf(to int, fx func(int, func()))

BackwardsIf takes a value and walks Backward till 0 unless the stop function is called

func BackwardsSkip

func BackwardsSkip(to int, fx func(int, func()))

BackwardsSkip takes a value and walks Backward till 0 unless the skip function is called it will go through all sequence

func Capitalize

func Capitalize(s string) string

Capitalize capitalizes the first character in a string

func ConvertToInt

func ConvertToInt(target string, def int) int

ConvertToInt wraps the internal int coverter

func Elapsed

func Elapsed(ms time.Time, diff time.Time) time.Duration

Elapsed takes a time and delta it from the current time to return a duration in milliseconds

func ElapsedIn

func ElapsedIn(ms time.Time, diff time.Time) int64

ElapsedIn returns the elapsed time in int64

func Failed

func Failed(msg string, v ...interface{}) string

Failed returns a msg with a x mark

func FatalFailed

func FatalFailed(fr FatalPrinter, msg string, v ...interface{})

FatalFailed uses the log to print out the failed message

func FatalPassed

func FatalPassed(fr FatalPrinter, msg string, v ...interface{})

FatalPassed uses the log to print out the passed message

func Forwards

func Forwards(to int, fx func(int))

Forwards takes a value and walks Backward till 0

func ForwardsIf

func ForwardsIf(to int, fx func(int, func()))

ForwardsIf takes a value and walks Backward till 0 unless the stop func is called

func ForwardsSkip

func ForwardsSkip(to int, fx func(int, func()))

ForwardsSkip takes a value and walks Backward till 0 unless the skip func is called it will go throuh all sequence

func GoDefer

func GoDefer(title string, fx func())

GoDefer letsw you run a function inside a goroutine that gets a defer recovery

func GoDeferCall

func GoDeferCall(title string, fx func(), cb func(interface{}))

GoDeferCall letsw you run a function inside a goroutine that gets a defer recovery

func GoSilent

func GoSilent(title string, fx func())

GoSilent letsw you run a function inside a goroutine that gets a defer recovery

func GoSilentCall

func GoSilentCall(title string, fx func(), cb func(interface{}))

GoSilentCall lets you run a function inside a goroutine that gets a defer recovery

func GzipWalker

func GzipWalker(file string, tmp io.Writer) error

GzipWalker walks a path and turns it into a tar written into a bytes.Buffer

func Lift

func Lift(conClose bool, rs ...Reactor)

Lift takes a set of Connectors and pipes the data from one to the next

func LiftOnly

func LiftOnly(rs ...Reactor)

LiftOnly calls the Lift function to lift the Reactors and sets the close bool to false to prevent closing each other

func LogFailed

func LogFailed(pr LogPrinter, msg string, v ...interface{})

LogFailed uses the log to print out the failed message

func LogPassed

func LogPassed(pr LogPrinter, msg string, v ...interface{})

LogPassed uses the log to print out the passed message

func MakeDuration

func MakeDuration(target string, def int) time.Duration

MakeDuration allows you to make create a duration from a string

func Passed

func Passed(msg string, v ...interface{}) string

Passed returns a msg with a check mark

func PrintFailed

func PrintFailed(pr SimplePrinter, msg string, v ...interface{})

PrintFailed uses the log to print out the failed message

func PrintPassed

func PrintPassed(pr SimplePrinter, msg string, v ...interface{})

PrintPassed uses the log to print out the passed message

func RandAlpha

func RandAlpha(n int) string

RandAlpha generates a set of random numbers of a set length

func RandString

func RandString(n int) string

RandString generates a set of random numbers of a set length

func RecoveryHandler

func RecoveryHandler(tag string, opFunc func() error) error

RecoveryHandler provides a recovery handler functions for use to automate the recovery processes

func RecoveryHandlerCallback

func RecoveryHandlerCallback(tag string, opFunc func() error, cb func(interface{})) error

RecoveryHandlerCallback provides a recovery handler functions for use to automate the recovery processes

func Report

func Report(e error, msg string)

Report provides a nice abstaction for doing basic report

func SilentRecoveryHandler

func SilentRecoveryHandler(tag string, opFunc func() error) error

SilentRecoveryHandler provides a recovery handler functions for use to automate the recovery processes

func SilentRecoveryHandlerCallback

func SilentRecoveryHandlerCallback(tag string, opFunc func() error, cb func(interface{})) error

SilentRecoveryHandlerCallback provides a recovery handler functions for use to automate the recovery processes

func TarWalker

func TarWalker(rootpath string, w io.Writer) error

TarWalker walks a path and turns it into a tar written into a bytes.Buffer

func ToCamelCase

func ToCamelCase(set []string) string

ToCamelCase takes a string set and returns the camelcase version

func ToDuration

func ToDuration(ms time.Time) time.Duration

ToDuration returns the duration in millisecond of a given time from the current time

func UnwrapAny

func UnwrapAny(a ActionInterface) (*Action, *ActDepend)

UnwrapAny returns two values where the first is not nil if the ActionInterface is a Action or the second non-nil if its a ActDepend

Types

type ActDepend

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

ActDepend provides a nice means of creating a new action depending on unfullfilled action

func NewActDepend

func NewActDepend(r ActionInterface, max int) *ActDepend

NewActDepend returns a action resolver based on a root action,when this root action is resolved,it waits on the user to call the actdepend then method to complete the next action,why so has to allow user-based chains where the user must partake in the completion of the final action

func NewActDependBy

func NewActDependBy(r ActionInterface, v ActionInterface, max int) *ActDepend

NewActDependBy provides the actdepend struct but allows specifying the next call in the chan

func NewActDependWith

func NewActDependWith(root ActionInterface, r ...ActionInterface) *ActDepend

NewActDependWith provides the actdepend struct but allows specifying the next call in the chan

func UnwrapActDepend

func UnwrapActDepend(a ActionInterface) *ActDepend

UnwrapActDepend unwraps an ActDepend that has being wrapped with ActionWrap

func UnwrapActDependWrap

func UnwrapActDependWrap(a ActionInterface) *ActDepend

UnwrapActDependWrap unwraps an ActDepend that has being wrapped with ActionWrap

func (*ActDepend) Chain

func (a *ActDepend) Chain(max int) *ActDepend

Chain returns ActDepend(ActionDepend) with this action as the root

func (*ActDepend) ChainAction

func (a *ActDepend) ChainAction(f ActionInterface) ActionInterface

ChainAction is a convenience method auto completes another action and returns that action,it uses UseThen underneath

func (*ActDepend) ChainLastAction

func (a *ActDepend) ChainLastAction(f ActionInterface) ActionInterface

ChainLastAction is a convenience method auto completes another action and returns that action,it uses UseThen underneath

func (*ActDepend) ChainWith

func (a *ActDepend) ChainWith(r ...ActionInterface) *ActDepend

ChainWith returns ActDepend(ActionDepend) with this action as the root

func (*ActDepend) End

func (a *ActDepend) End()

End stops the generation of new chain

func (*ActDepend) EqualRoot

func (a *ActDepend) EqualRoot(r ActionInterface) bool

EqualRoot returns true/false if the root is equal

func (*ActDepend) First

func (a *ActDepend) First() ActionInterface

First returns the first ActionInterface in the dependency stack

func (*ActDepend) Fullfill

func (a *ActDepend) Fullfill(b interface{})

Fullfill actually fullfills the root action if its not fullfilled already

func (*ActDepend) Fullfilled

func (a *ActDepend) Fullfilled() bool

Fullfilled returns true or false if the action is done

func (*ActDepend) IsIndexFullfilled

func (a *ActDepend) IsIndexFullfilled(ind int) bool

IsIndexFullfilled returns true/false if the action at the index is fullfilled

func (*ActDepend) Last

func (a *ActDepend) Last() ActionInterface

Last returns the last ActionInterface in the dependency stack

func (*ActDepend) Mix

func (a *ActDepend) Mix(ind int, base ActionInterface)

Mix base the completion of action at a index with a custom action point using OverrideBefore and allows adding an extra step into the dependency action roadmap i.e when the next chain at this index which will complete the next chain if it is not the last as the normal operation of OverrideBefore it will base the completion of that next action on the action being mixed instead of the action at that index,like adding a middleman to a middleman :)

func (*ActDepend) MixLast

func (a *ActDepend) MixLast(ind int, base ActionInterface)

MixLast base adds a new action into the current action stack and calls inserts a ghost action inbetween the action at the index and the next action,when the ghost action is fullfilled the next action is fullfilled It underneaths calls the Action.ChainLastAction which when an ActDepend will resolve the next after the last action has been dissolved

func (*ActDepend) OverrideAfter

func (a *ActDepend) OverrideAfter(index int, fx func(b interface{}, a ActionInterface)) ActionInterface

OverrideAfter allows calling Then with an action after the current index that is you want to listen to the action at this index to fullfill the next index

func (*ActDepend) OverrideBefore

func (a *ActDepend) OverrideBefore(index int, fx func(b interface{}, a ActionInterface)) ActionInterface

OverrideBefore allows calling Then with an action before the current index that is you want to listen to the action at this previous index to fullfill the this action at this index

func (*ActDepend) Size

func (a *ActDepend) Size() int

Size returns the total actions in list

func (*ActDepend) Sync

func (a *ActDepend) Sync(ms int) <-chan interface{}

Sync returns unbuffered channel which will get resolved with the value of the action when fullfilled

func (*ActDepend) Then

func (a *ActDepend) Then(fx func(b interface{}, a ActionInterface)) ActionInterface

Then adds a function to the action stack or fires immediately if done

func (*ActDepend) Use

func (a *ActDepend) Use(ind int) ActionInterface

Use returns the ActionInterface wrapped by an ActionWrap at the index or nil and supports negative indexing

func (*ActDepend) UseThen

func (a *ActDepend) UseThen(fx func(b interface{}, a ActionInterface), f ActionInterface) ActionInterface

UseThen adds a function with a ActionInterface to the action stack or fires immediately if done once done that action interface is returned

func (*ActDepend) When

func (a *ActDepend) When(fx func(b interface{}, a ActionInterface)) ActionInterface

When adds a function to the action stack with the action as the second arg

func (*ActDepend) WhenOnly

func (a *ActDepend) WhenOnly(fx func(b interface{})) ActionInterface

WhenOnly adds a function to the action stack with the action as the second arg

func (*ActDepend) Wrap

func (a *ActDepend) Wrap() *ActionWrap

Wrap returns actionwrap for the action

type Action

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

Action provides a future-style connect approach

func NewAction

func NewAction() *Action

NewAction returns a new Action struct

func UnwrapAction

func UnwrapAction(a ActionInterface) *Action

UnwrapAction unwraps an ActionInterface to a *Action

func UnwrapActionWrap

func UnwrapActionWrap(a ActionInterface) *Action

UnwrapActionWrap unwraps an action that has being wrapped with ActionWrap

func (*Action) Chain

func (a *Action) Chain(max int) *ActDepend

Chain returns ActDepend(ActionDepend) with this action as the root

func (*Action) ChainAction

func (a *Action) ChainAction(f ActionInterface) ActionInterface

ChainAction is a convenience method auto completes another action and returns that action,it uses UseThen underneath

func (*Action) ChainLastAction

func (a *Action) ChainLastAction(f ActionInterface) ActionInterface

ChainLastAction is a convenience method auto completes another action and returns that action,it uses UseThen underneath

func (*Action) ChainWith

func (a *Action) ChainWith(r ...ActionInterface) *ActDepend

ChainWith returns ActDepend(ActionDepend) with this action as the root

func (*Action) Fullfill

func (a *Action) Fullfill(b interface{})

Fullfill meets this action of this structure

func (*Action) Fullfilled

func (a *Action) Fullfilled() bool

Fullfilled returns true or false if the action is done

func (*Action) Sync

func (a *Action) Sync(ms int) <-chan interface{}

Sync returns unbuffered channel which will get resolved with the value of the action when fullfilled or when the supplied value of time has passed it will eject

func (*Action) Then

func (a *Action) Then(fx func(b interface{}, a ActionInterface)) ActionInterface

Then adds a function to the action stack or fires immediately if done

func (*Action) UseThen

func (a *Action) UseThen(fx func(b interface{}, a ActionInterface), f ActionInterface) ActionInterface

UseThen adds a function with a ActionInterface to the action stack or fires immediately if done once done that action interface is returned

func (*Action) When

func (a *Action) When(fx func(b interface{}, e ActionInterface)) ActionInterface

When adds a function to the action stack with the action as the second arg

func (*Action) WhenOnly

func (a *Action) WhenOnly(fx func(b interface{})) ActionInterface

WhenOnly adds a function to the action stack with the action as the second arg

func (*Action) Wrap

func (a *Action) Wrap() *ActionWrap

Wrap returns actionwrap for the action

type ActionInterface

type ActionInterface interface {
	Fullfill(b interface{})
	WhenOnly(fx func(interface{})) ActionInterface
	When(fx func(interface{}, ActionInterface)) ActionInterface
	Then(fx func(interface{}, ActionInterface)) ActionInterface
	UseThen(fx func(interface{}, ActionInterface), a ActionInterface) ActionInterface
	Fullfilled() bool
	ChainAction(ActionInterface) ActionInterface
	ChainLastAction(ActionInterface) ActionInterface
	Chain(int) *ActDepend
	ChainWith(...ActionInterface) *ActDepend
	Wrap() *ActionWrap
	Sync(int) <-chan interface{}
}

ActionInterface defines member functions

type ActionMod

ActionMod defines a function type that modifies a actionstack actions and returns them or the new actions

type ActionStack

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

ActionStack provides two internal stack for success and error

func NewActionStack

func NewActionStack() *ActionStack

NewActionStack returns a new actionStack

func NewActionStackBy

func NewActionStackBy(d ActionInterface, e ActionInterface) *ActionStack

NewActionStackBy returns a new actionstack with the predefined actions from a previous actionstack with modification

func NewActionStackFrom

func NewActionStackFrom(a ActionStackInterface, mod ActionMod) *ActionStack

NewActionStackFrom returns a new actionstack with the predefined actions from a previous actionstack with modification

func (*ActionStack) Complete

func (a *ActionStack) Complete(b interface{}) ActionInterface

Complete allows completion of an action stack

func (*ActionStack) Done

func (a *ActionStack) Done() ActionInterface

Done returns the action for the done state

func (*ActionStack) Error

func (a *ActionStack) Error() ActionInterface

Error returns the action for the error state

type ActionStackInterface

type ActionStackInterface interface {
	Complete(b interface{}) ActionInterface
	Done() ActionInterface
	Error() ActionInterface
}

ActionStackInterface defines actionstack member method rules

type ActionWrap

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

ActionWrap safty wraps action for limited access to its fullfill function

func NewActionWrap

func NewActionWrap(a *Action) *ActionWrap

NewActionWrap returns a action wrapped in a actionwrap

func (*ActionWrap) Chain

func (a *ActionWrap) Chain(m int) *ActDepend

Chain returns ActDepend(ActionDepend) with this action as the root

func (*ActionWrap) ChainAction

func (a *ActionWrap) ChainAction(f ActionInterface) ActionInterface

ChainAction is a convenience method auto completes another action and returns that action,it uses UseThen underneath

func (*ActionWrap) ChainLastAction

func (a *ActionWrap) ChainLastAction(f ActionInterface) ActionInterface

ChainLastAction is a convenience method auto completes another action and returns that action,it uses UseThen underneath

func (*ActionWrap) ChainWith

func (a *ActionWrap) ChainWith(r ...ActionInterface) *ActDepend

ChainWith returns ActDepend(ActionDepend) with this action as the root

func (*ActionWrap) Fullfill

func (a *ActionWrap) Fullfill(b interface{})

Fullfill meets this action of this structure

func (*ActionWrap) Fullfilled

func (a *ActionWrap) Fullfilled() bool

Fullfilled returns true or false if the action is done

func (*ActionWrap) Sync

func (a *ActionWrap) Sync(ms int) <-chan interface{}

Sync returns unbuffered channel which will get resolved with the value of the action when fullfilled

func (*ActionWrap) Then

func (a *ActionWrap) Then(fx func(b interface{}, a ActionInterface)) ActionInterface

Then adds a function to the action stack or fires immediately if done

func (*ActionWrap) UseThen

func (a *ActionWrap) UseThen(fx func(b interface{}, a ActionInterface), f ActionInterface) ActionInterface

UseThen adds a function with a ActionInterface to the action stack or fires immediately if done once done that action interface is returned

func (*ActionWrap) When

func (a *ActionWrap) When(fx func(b interface{}, a ActionInterface)) ActionInterface

When adds a function to the action stack with the action as the second arg

func (*ActionWrap) WhenOnly

func (a *ActionWrap) WhenOnly(fx func(b interface{})) ActionInterface

WhenOnly adds a function to the action stack with the action as the second arg

func (*ActionWrap) Wrap

func (a *ActionWrap) Wrap() *ActionWrap

Wrap returns actionwrap for the action

type Buffer

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

Buffer provides a infinite receive space for handling incoming data, providing a good back pressure mechanism

func NewBuffer

func NewBuffer() *Buffer

NewBuffer returns a new Buffer instance

func (*Buffer) Clear

func (b *Buffer) Clear()

Clear emties the buffer of current content

func (*Buffer) Dequeue

func (b *Buffer) Dequeue() (interface{}, error)

Dequeue removes an item into the buffers front

func (*Buffer) Enqueue

func (b *Buffer) Enqueue(item interface{})

Enqueue adds an item into the buffers end

func (*Buffer) Length

func (b *Buffer) Length() int

Length returns the current size of element in the buffer

func (*Buffer) Peek

func (b *Buffer) Peek() (interface{}, error)

Peek returns the first value in the buffer or an error if empty

type BufferCloser

type BufferCloser struct {
	*bytes.Buffer
}

BufferCloser closes a byte.Buffer

func NewBufferCloser

func NewBufferCloser(bu *bytes.Buffer) *BufferCloser

NewBufferCloser returns a new closer for a bytes.Buffer

func (*BufferCloser) Close

func (b *BufferCloser) Close() error

Close resets the internal buffer

type ChannelStream

type ChannelStream struct {
	Data  chan interface{}
	Error chan error
	// contains filtered or unexported fields
}

ChannelStream provides a simple struct for exposing outputs from Reactor to outside

func NewChannelStream

func NewChannelStream() *ChannelStream

NewChannelStream returns a new channel stream instance with blocked channels, so ensure to fullfill the contract of removing the data you need only

func (*ChannelStream) Close

func (c *ChannelStream) Close()

Close ends the capability to use the ChannelStream channels

func (*ChannelStream) Listen

func (c *ChannelStream) Listen(m Reactor)

Listen binds into a reactor and will pipe any response into its Data or Error channels, always use this to bind to reactors, to ensure safety in code use i.e dont try to pipe into the channels your own way

type CloseIndicator

type CloseIndicator interface {
	CloseNotify() <-chan bool
}

CloseIndicator was created as a later means of providing a simply indicator of the close state of a Reactor

type Collector

type Collector map[string]interface{}

Collector defines a typ of map string

func NewCollector

func NewCollector() Collector

NewCollector returns a new collector instance

func (Collector) Clear

func (c Collector) Clear()

Clear clears the collector

func (Collector) Clone

func (c Collector) Clone() Collector

Clone makes a new clone of this collector

func (Collector) Copy

func (c Collector) Copy(m map[string]interface{})

Copy copies the map into the collector

func (Collector) Each

func (c Collector) Each(fx StringEachfunc)

Each iterates through all items in the collector

func (Collector) Get

func (c Collector) Get(k string) interface{}

Get returns the value with the key

func (Collector) Has

func (c Collector) Has(k string) bool

Has returns if a key exists

func (Collector) HasMatch

func (c Collector) HasMatch(k string, v interface{}) bool

HasMatch checks if key and value exists and are matching

func (Collector) Keys

func (c Collector) Keys() []string

Keys return the keys of the Collector

func (Collector) Remove

func (c Collector) Remove(k string)

Remove deletes a key:value pair

func (Collector) Set

func (c Collector) Set(k string, v interface{})

Set puts a specific key:value into the collector

type Collectors

type Collectors interface {
	Maps
	Clone() Collector
}

Collectors defines member function rules for collector

type Connector

type Connector interface {
	// Bind provides a convenient way of binding 2 reactors
	Bind(r Reactor, closeAlong bool)
	// React generates a reactor based off its caller
	React(s SignalMuxHandler, closeAlong bool) Reactor
}

Connector defines the core connecting methods used for binding with a Reactor

type Detacher

type Detacher interface {
	Detach(Reactor)
}

Detacher details the detach interface used by the Reactor

type Eachfunc

type Eachfunc func(interface{}, interface{}, func())

Eachfunc defines the type of the Mappable.Each rule

type FatalPrinter

type FatalPrinter interface {
	Fatal(v ...interface{})
}

FatalPrinter provides a hasher,stop after print interface with Fatal function

type FileCloser

type FileCloser struct {
	*os.File
	// contains filtered or unexported fields
}

FileCloser provides a means of closing a file

func NewFileCloser

func NewFileCloser(path string) (*FileCloser, error)

NewFileCloser returns a new file closer

func (*FileCloser) Close

func (f *FileCloser) Close() error

Close ends and deletes the file

type FlatChain

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

FlatChain provides a simple middleware like

func NewFlatChain

func NewFlatChain(fx FlatHandler) *FlatChain

NewFlatChain returns a new flatchain instance

func (*FlatChain) Call

func (r *FlatChain) Call(err error, d interface{})

Call calls the next chain if any

func (*FlatChain) Next

func (r *FlatChain) Next(rx FlatChains)

Next sets the next flat chains else passes it down to the last chain to set as next chain

type FlatChains

type FlatChains interface {
	Call(error, interface{})
	Next(FlatChains)
}

FlatChains define a simple flat chain

type FlatHandler

type FlatHandler func(error, interface{}, NextHandler)

FlatHandler provides a handler for flatchain

type FlatReactor

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

FlatReactor provides a pure functional reactor which uses an internal wait group to ensure if close is called that call values where delivered

func FlatIdentity

func FlatIdentity() *FlatReactor

FlatIdentity returns flatreactor that resends its inputs as outputs with no changes

func FlatReactive

func FlatReactive(op SignalMuxHandler) *FlatReactor

FlatReactive returns a new functional reactor

func (*FlatReactor) Bind

func (f *FlatReactor) Bind(rx Reactor, cl bool)

Bind connects two reactors

func (*FlatReactor) Close

func (f *FlatReactor) Close() error

Close closes the reactor and removes all connections

func (*FlatReactor) CloseNotify

func (f *FlatReactor) CloseNotify() <-chan bool

CloseNotify provides a channel for notifying a close event

func (*FlatReactor) Detach

func (f *FlatReactor) Detach(rm Reactor)

Detach removes the given reactor from its connections

func (*FlatReactor) React

func (f *FlatReactor) React(op SignalMuxHandler, cl bool) Reactor

React builds a new reactor from this one

func (*FlatReactor) Reply

func (f *FlatReactor) Reply(v interface{})

Reply allows the reply of an data message

func (*FlatReactor) ReplyError

func (f *FlatReactor) ReplyError(err error)

ReplyError allows the reply of an error message

func (*FlatReactor) Send

func (f *FlatReactor) Send(b interface{})

Send applies a message value to the handler

func (*FlatReactor) SendError

func (f *FlatReactor) SendError(err error)

SendError applies a error value to the handler

func (*FlatReactor) UseRoot

func (f *FlatReactor) UseRoot(rx Reactor)

UseRoot Adds this reactor as a root of the called reactor

type FuncWriter

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

FuncWriter provides a means of creation io.Writer on functions

func NewFuncWriter

func NewFuncWriter(fx func([]byte)) *FuncWriter

NewFuncWriter returns a new function writer instance

func (*FuncWriter) Close

func (w *FuncWriter) Close() error

Close provides a basic io.WriteCloser write method

func (*FuncWriter) Write

func (w *FuncWriter) Write(b []byte) (int, error)

Write provides a basic io.Writer write method

type FunctionStack

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

FunctionStack provides addition of functions into a stack

func NewFunctionStack

func NewFunctionStack() *FunctionStack

NewFunctionStack returns a new functionstack instance

func (*FunctionStack) Add

func (f *FunctionStack) Add(fx func(...interface{})) int

Add adds a function into the stack

func (*FunctionStack) Clear

func (f *FunctionStack) Clear()

Clear flushes the stack listener

func (*FunctionStack) Delete

func (f *FunctionStack) Delete(ind int)

Delete removes the function at the provided index

func (*FunctionStack) Each

func (f *FunctionStack) Each(d ...interface{})

Each runs through the function lists and executing with args

func (*FunctionStack) Size

func (f *FunctionStack) Size() int

Size returns the total number of listeners

type LogPrinter

type LogPrinter interface {
	Log(v ...interface{})
}

LogPrinter provides a simple printer interface with normal log function

type Mappable

type Mappable interface {
	Clear()
	HasMatch(k, v interface{}) bool
	Each(f Eachfunc)
	Keys() []interface{}
	Copy(map[interface{}]interface{})
	CopySecureMap(Mappable)
	Has(interface{}) bool
	Get(interface{}) interface{}
	Remove(interface{})
	Set(k, v interface{})
	Clone() Mappable
}

Mappable defines member function rules for securemap

type Maps

type Maps interface {
	Clear()
	HasMatch(k string, v interface{}) bool
	Each(f StringEachfunc)
	Keys() []string
	Copy(map[string]interface{})
	Has(string) bool
	Get(string) interface{}
	Remove(string)
	Set(k string, v interface{})
}

Maps define a set of method rules for maps of the string key types

type NextHandler

type NextHandler func(error, interface{})

NextHandler provides next call for flat chains

type PoolConfig

type PoolConfig struct {
	MaxWorkers     int64
	MinWorkers     int64
	MetricInterval func() time.Duration
	MetricHandler  func(PoolStat)
}

PoolConfig defines the configuration details for a workpool

type PoolStat

type PoolStat struct {
	//date of the state
	Stamp time.Time

	MaxWorkers int64
	MinWorkers int64
	//total current workers goroutined
	Workers int64

	//total executed works
	Executed int64
	//pending work in pool
	Pending int64
	//active work in pool
	Active int64
}

PoolStat defines the stat returned when checking health of pool

type PressureStream

type PressureStream struct {
	Signals, Errors chan interface{}
	// contains filtered or unexported fields
}

PressureStream provides a higher api for handling pressure requests of two levels (data and errors),there by providing a simple but strong foundation for higher level constructs

func BuildPressureStream

func BuildPressureStream(dataSignals, errorSignals chan interface{}) *PressureStream

BuildPressureStream returns a new PressureStream instance

func NewPressureStream

func NewPressureStream() *PressureStream

NewPressureStream returns a new PressureStream

func (*PressureStream) Close

func (ps *PressureStream) Close()

Close closes the PressureStream but ensures the function only returns control when the both back queues have been closed

func (*PressureStream) RemainingErrors

func (ps *PressureStream) RemainingErrors() int

RemainingErrors returns the current size of error queue

func (*PressureStream) RemainingSignals

func (ps *PressureStream) RemainingSignals() int

RemainingSignals returns the current size of signal queue

func (*PressureStream) SendError

func (ps *PressureStream) SendError(d error)

SendError delivers data into the data channel

func (*PressureStream) SendSignal

func (ps *PressureStream) SendSignal(d interface{})

SendSignal delivers data into the data channel

type Queue

type Queue struct {
	Deq chan interface{}
	// contains filtered or unexported fields
}

Queue is a simple queue with the capability of handling infinite receivals and retrieving with a more control system

func NewQueue

func NewQueue(deq chan interface{}) *Queue

NewQueue returns a new pressure queue

func (*Queue) Close

func (q *Queue) Close()

Close sets the internal operations channels to a close state and waits till the buffer operations are complete to return, hence ensuring the last items where delivered

func (*Queue) Enqueue

func (q *Queue) Enqueue(item interface{})

Enqueue adds a new item into the queue's buffer with a guarantee that it was received before returned and manages concurrency by locking the function until the data as being received

func (*Queue) Length

func (q *Queue) Length() int

Length returns the length of items within the queue's buffer

type Reactor

type Reactor interface {
	io.Closer
	CloseIndicator
	Connector
	Sender
	Replier
	Detacher

	UseRoot(Reactor)
}

Reactor provides an interface definition for the reactor type to allow compatibility by future extenders when composing with other structs.

func DistributeSignals

func DistributeSignals(rs Reactor, ms ...Sender) Reactor

DistributeSignals provide a function that takes a React and other multiple Reactors and distribute the data from the first reactor to others

func FileLoader

func FileLoader() Reactor

FileLoader provides an adaptor to load a file path

func FlatAlways

func FlatAlways(v interface{}) Reactor

FlatAlways returns a reactor with consistently returns the provided value

func FlatSimple

func FlatSimple(fx func(Reactor, interface{})) Reactor

FlatSimple returns a reactor using the SimpleMuxer as a mux generator

func FlatStack

func FlatStack() Reactor

FlatStack returns a flat reactor

func JSONReactor

func JSONReactor() Reactor

JSONReactor provides a json encoding Reactor,takes any input and tries to transform it into a json using the default json.Marshal function

func LiftOut

func LiftOut(conClose bool, rs ...Reactor) Reactor

LiftOut uses Lift to chain a set of reactors and returns a new reactor which is the last in the chain

func MergeReactors

func MergeReactors(rs ...Reactor) Reactor

MergeReactors merges data from a set of Senders into a new reactor stream

func QueueReactor

func QueueReactor(ps *PressureStream) (qr Reactor)

QueueReactor provides a reactor that listens on the supplied queue for data and error messages but if the queue gets closed then the reactor is closed along

func ReactIdentity

func ReactIdentity() Reactor

ReactIdentity is more written to provide a backward compatibility for cold using the old channel based reactor

func Reactive

func Reactive(fx SignalMuxHandler) Reactor

Reactive returns a ReactiveStacks

func ReactorStack

func ReactorStack() Reactor

ReactorStack returns a Stacker as a reactor with an identity reactor as root

type Replier

type Replier interface {
	Reply(v interface{})
	ReplyError(v error)
}

Replier defines reply methods to reply to requests

type ReplyCloser

type ReplyCloser interface {
	Replier
	io.Closer
}

ReplyCloser provides an interface that combines Replier and Closer interfaces

type ResetTimer

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

ResetTimer runs a timer and performs an action

func NewResetTimer

func NewResetTimer(init func(), done func(), d time.Duration, run, boot bool) *ResetTimer

NewResetTimer returns a new reset timer

func (*ResetTimer) Add

func (r *ResetTimer) Add()

Add reset the timer threshold

func (*ResetTimer) Close

func (r *ResetTimer) Close()

Close closes this timer

type SecureMap

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

SecureMap simple represents a map with a rwmutex locked in

func NewSecureMap

func NewSecureMap() *SecureMap

NewSecureMap returns a new securemap

func SecureMapFrom

func SecureMapFrom(core map[interface{}]interface{}) *SecureMap

SecureMapFrom returns a new securemap

func (*SecureMap) Clear

func (m *SecureMap) Clear()

Clear unlinks the previous map

func (*SecureMap) Clone

func (m *SecureMap) Clone() Mappable

Clone makes a clone for this securemap

func (*SecureMap) Copy

func (m *SecureMap) Copy(src map[interface{}]interface{})

Copy Copies a map[interface{}]interface{} into the map

func (*SecureMap) CopySecureMap

func (m *SecureMap) CopySecureMap(src Mappable)

CopySecureMap Copies a into the map

func (*SecureMap) Each

func (m *SecureMap) Each(fn Eachfunc)

Each interates through the map

func (*SecureMap) Get

func (m *SecureMap) Get(key interface{}) interface{}

Get a key's value

func (*SecureMap) Has

func (m *SecureMap) Has(key interface{}) bool

Has returns true/false if value exists by key

func (*SecureMap) HasMatch

func (m *SecureMap) HasMatch(key, value interface{}) bool

HasMatch checks if a key exists and if the value matches

func (*SecureMap) Keys

func (m *SecureMap) Keys() []interface{}

Keys return the keys of the map

func (*SecureMap) Remove

func (m *SecureMap) Remove(key interface{})

Remove a value by its key

func (*SecureMap) Set

func (m *SecureMap) Set(key, value interface{})

Set a key with value

type SecureStack

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

SecureStack provides addition of functions into a stack

func NewSecureStack

func NewSecureStack() *SecureStack

NewSecureStack returns a new concurrent safe array decorator

func (*SecureStack) Add

func (f *SecureStack) Add(fx interface{}) int

Add adds a function into the stack

func (*SecureStack) Clear

func (f *SecureStack) Clear()

Clear flushes the stack listener

func (*SecureStack) Delete

func (f *SecureStack) Delete(ind int)

Delete removes the function at the provided index

func (*SecureStack) Each

func (f *SecureStack) Each(fx func(interface{}))

Each runs through the function lists and executing with args

func (*SecureStack) Get

func (f *SecureStack) Get(ind int) interface{}

Get lets you retrieve an item in the list

func (*SecureStack) Set

func (f *SecureStack) Set(ind int, d interface{})

Set lets you retrieve an item in the list

func (*SecureStack) Size

func (f *SecureStack) Size() int

Size returns the total number of listeners

func (*SecureStack) Splice

func (f *SecureStack) Splice(begin, end int) []interface{}

Splice returns a new unique slice from the list

func (*SecureStack) String

func (f *SecureStack) String() string

Strings return the stringified version of the internal list

type SendBinder

type SendBinder interface {
	Sender
	Connector
}

SendBinder defines the combination of the Sender and Binding interfaces

type SendCloser

type SendCloser interface {
	Sender
	io.Closer
}

SendCloser provides an interface that combines Sender and Closer interfaces

type SendReplier

type SendReplier interface {
	Replier
	Sender
}

SendReplier provides the interface for the combination of senders and repliers

type SendReplyCloser

type SendReplyCloser interface {
	io.Closer
	Replier
	Sender
}

SendReplyCloser provides the interface for the combination of closers,senders and repliers

type SendReplyDetachCloser

type SendReplyDetachCloser interface {
	io.Closer
	Replier
	Sender
	Detacher
}

SendReplyDetachCloser provides the interface for the combination of closers, senders,detachers and repliers

type SendReplyDetacher

type SendReplyDetacher interface {
	Replier
	Sender
	Detacher
}

SendReplyDetacher provides the interface for the combination of senders,detachers and repliers

type Sender

type Sender interface {
	Send(v interface{})
	SendError(v error)
}

Sender defines the delivery methods used to deliver data into Reactor process

type SenderDetachCloser

type SenderDetachCloser interface {
	Sender
	Detacher
	io.Closer
}

SenderDetachCloser provides an interface that combines Sender and Closer interfaces

type SignalMuxHandler

type SignalMuxHandler func(reactor Reactor, failure error, signal interface{})

SignalMuxHandler provides a signal function type:

  It takes three arguments:
		- reactor:(Reactor) the reactor itself for reply processing
		- failure:(error) the current error being returned when a data is nil
		- data:(interface{}) the current data being returned,nil when theres an error

func IdentityMuxer

func IdentityMuxer() SignalMuxHandler

IdentityMuxer provides the handoler for a providing a pure piping behaviour where data is left untouched as it comes in and goes out

func IdentityValueMuxer

func IdentityValueMuxer(v interface{}) SignalMuxHandler

IdentityValueMuxer provides the handler for a providing a pure piping behaviour where data passed in is used as the return data value

func SimpleMuxer

func SimpleMuxer(fx func(Reactor, interface{})) SignalMuxHandler

SimpleMuxer provides the handoler for a providing a pure piping behaviour where data is left untouched as it comes in and goes out

type SimplePrinter

type SimplePrinter interface {
	Print(v ...interface{})
}

SimplePrinter provides a simple printer interface with normal print function

type SingleStack

type SingleStack struct {
	*FunctionStack
}

SingleStack provides a function stack fro single argument functions

func NewSingleStack

func NewSingleStack() *SingleStack

NewSingleStack returns a singlestack instance

func (*SingleStack) Add

func (s *SingleStack) Add(fx func(interface{})) int

Add adds a function into the stack

type Stackers

type Stackers struct {
	Reactor
	// contains filtered or unexported fields
}

Stackers provides a construct for providing a strict top-down method call for the Bind,React and BindControl for Reactors,it allows passing these function requests to the last Reactor in the stack while still passing data from the top

func ReactStack

func ReactStack(root Reactor) *Stackers

ReactStack returns a new Reactor based off the Stacker struct which is safe for concurrent use

func (*Stackers) Bind

func (sr *Stackers) Bind(r Reactor, cl bool)

Bind wraps the bind method of the Reactor,if no Reactor has been stack then it binds with the root else gets the last Reactor and binds with that instead

func (*Stackers) Clear

func (sr *Stackers) Clear()

Clear clears the stacks and resolves back to root

func (*Stackers) Close

func (sr *Stackers) Close() error

Close wraps the internal close method of the root

func (*Stackers) Last

func (sr *Stackers) Last() (Connector, error)

Last returns the last Reactors stacked

func (*Stackers) Length

func (sr *Stackers) Length() int

Length returns the total stack Reactors

func (*Stackers) React

func (sr *Stackers) React(s SignalMuxHandler, cl bool) Reactor

React wraps the root React() method and stacks the return Reactor or passes it to the last stacked Reactor and stacks that returned reactor for next use

type StringEachfunc

type StringEachfunc func(interface{}, string, func())

StringEachfunc defines the type of the Mappable.Each rule

type StringMappable

type StringMappable interface {
	Maps
	Clone() StringMappable
}

StringMappable defines member function rules for securemap

type SwitchInterface

type SwitchInterface interface {
	Switch()
	IsOn() bool
	WhenOn() ActionInterface
	WhenOff() ActionInterface
}

SwitchInterface defines a flux.Switch interface method definition

type SyncCollector

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

SyncCollector provides a mutex controlled map

func NewSyncCollector

func NewSyncCollector() *SyncCollector

NewSyncCollector returns a new collector instance

func (*SyncCollector) Clear

func (c *SyncCollector) Clear()

Clear clears the collector

func (*SyncCollector) Clone

func (c *SyncCollector) Clone() SyncCollectors

Clone makes a new clone of this collector

func (*SyncCollector) Copy

func (c *SyncCollector) Copy(m map[string]interface{})

Copy copies the map into the collector

func (*SyncCollector) Each

func (c *SyncCollector) Each(fx StringEachfunc)

Each iterates through all items in the collector

func (*SyncCollector) Get

func (c *SyncCollector) Get(k string) interface{}

Get returns the value with the key

func (*SyncCollector) Has

func (c *SyncCollector) Has(k string) bool

Has returns if a key exists

func (*SyncCollector) HasMatch

func (c *SyncCollector) HasMatch(k string, v interface{}) bool

HasMatch checks if key and value exists and are matching

func (*SyncCollector) Keys

func (c *SyncCollector) Keys() []string

Keys return the keys of the Collector

func (*SyncCollector) Remove

func (c *SyncCollector) Remove(k string)

Remove deletes a key:value pair

func (*SyncCollector) Set

func (c *SyncCollector) Set(k string, v interface{})

Set puts a specific key:value into the collector

type SyncCollectors

type SyncCollectors interface {
	Maps
	Clone() SyncCollectors
}

SyncCollectors defines member function rules for SyncCollector

type TimeWait

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

TimeWait defines a time lock waiter

func NewTimeWait

func NewTimeWait(max int, duration time.Duration) *TimeWait

NewTimeWait returns a new timer wait locker You specifiy two arguments: max int: the maximum number of time you want to check for idleness duration time.Duration: the time to check for each idle times and reduce until zero is reached then close eg. to do a 15seconds check for idleness NewTimeWait(15,time.Duration(1)*time.Second) eg. to do a 25 maximum check before closing per minute NewTimeWait(15,time.Duration(1)*time.Minute)

func (*TimeWait) Add

func (w *TimeWait) Add()

Add increments the lock state to the lock counter unless its already unlocked

func (*TimeWait) Count

func (w *TimeWait) Count() int

Count returns the total left count to completed before unlock

func (*TimeWait) Done

func (w *TimeWait) Done()

Done decrements the totalcount of this waitlocker by 1 until its below zero and fullfills with the 0 value

func (*TimeWait) Flush

func (w *TimeWait) Flush()

Flush drops the lock count and forces immediate unlocking of the wait

func (TimeWait) Then

func (w TimeWait) Then() ActionInterface

Then returns an ActionInterface which gets fullfilled when this wait counter reaches zero

type Wait

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

Wait implements the WiatInterface for creating a wait lock which waits until the lock lockcount is finished then executes a action can only be used once, that is ,once the wait counter is -1,you cant add to it anymore

func (*Wait) Add

func (w *Wait) Add()

Add increments the lock state to the lock counter unless its already unlocked

func (*Wait) Count

func (w *Wait) Count() int

Count returns the total left count to completed before unlock

func (*Wait) Done

func (w *Wait) Done()

Done decrements the totalcount of this waitlocker by 1 until its below zero and fullfills with the 0 value

func (*Wait) Flush

func (w *Wait) Flush()

Flush drops the lock count and forces immediate unlocking of the wait

func (Wait) Then

func (w Wait) Then() ActionInterface

Then returns an ActionInterface which gets fullfilled when this wait counter reaches zero

type WaitGen

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

WaitGen is a nice way of creating regenerative timers for use wait timers are once timers, once they are clocked out they are of no more use,to allow their nature which has its benefits we get to create WaitGen that generates a new once once a wait gen is over

func NewSimpleWaitGen

func NewSimpleWaitGen(init func(WaitInterface)) *WaitGen

NewSimpleWaitGen returns a wait generator making a timewaiter

func NewTimeWaitGen

func NewTimeWaitGen(steps int, ms time.Duration, init func(WaitInterface)) *WaitGen

NewTimeWaitGen returns a wait generator making a timewaiter

func (*WaitGen) Make

func (w *WaitGen) Make() WaitInterface

Make returns a new WaitInterface or returns the current once

type WaitInterface

type WaitInterface interface {
	Add()
	Done()
	Count() int
	Flush()
	Then() ActionInterface
}

WaitInterface defines the flux.Wait interface method definitions

func NewWait

func NewWait() WaitInterface

NewWait returns a new Wait instance for the WaitInterface

type Work

type Work interface {
	Work(context interface{}, id int)
}

Work defines an interface for a work to be performed

type WorkPool

type WorkPool struct {
	*PoolConfig
	// contains filtered or unexported fields
}

WorkPool defines a pool for handling workers

func NewPool

func NewPool(context interface{}, name string, config *PoolConfig) (*WorkPool, error)

NewPool creates a new pool instance

func (*WorkPool) Add

func (w *WorkPool) Add(context interface{}, do int) error

Add adds or removes a worker from the active routines

func (*WorkPool) Do

func (w *WorkPool) Do(c interface{}, wo Work)

Do adds a task into the pool and blocks until it is accepted

func (*WorkPool) DoWait

func (w *WorkPool) DoWait(c interface{}, wo Work, t time.Duration) error

DoWait adds a task into the pool within a given duration if not accepted by then it returns with an error

func (*WorkPool) Name

func (w *WorkPool) Name() string

Name returns the name of workpool

func (*WorkPool) Reset

func (w *WorkPool) Reset(context interface{}, rmw int)

Reset resets the total allowed routines to the given value

func (*WorkPool) Shutdown

func (w *WorkPool) Shutdown()

Shutdown ends the workpool and all workers and jobs

func (*WorkPool) Stat

func (w *WorkPool) Stat() PoolStat

Stat returns the current stat of the pool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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