Documentation ¶
Index ¶
- Constants
- Variables
- func Copy(i interface{}) interface{}
- func GetLibrary() map[string]Spec
- func GetSources() map[string]SourceSpec
- func MergeMap(base, tomerge map[string]interface{}) (map[string]interface{}, error)
- func NewError(s string) *stcoreError
- type Block
- func (b *Block) Connect(id RouteIndex, c Connection) error
- func (b *Block) Disconnect(id RouteIndex, c Connection) error
- func (b *Block) GetInput(id RouteIndex) (Input, error)
- func (b *Block) GetInputs() []Input
- func (b *Block) GetOutputs() []Output
- func (b *Block) GetSource() Source
- func (b *Block) Reset()
- func (b *Block) Serve()
- func (b *Block) SetInput(id RouteIndex, v *InputValue) error
- func (b *Block) SetSource(s Source) error
- func (b *Block) Stop()
- type BlockInfo
- type BlockRouting
- type BlockState
- type Connection
- type Input
- type InputValue
- type Interface
- type Interrupt
- type JSONType
- type Kernel
- type KeyValue
- type List
- type Manifest
- type ManifestPair
- type Message
- type MessageMap
- type MonitorMessage
- type NSQConf
- type NSQConsumer
- type NSQMsg
- type Output
- type PQMessage
- type Pin
- type PriorityQueue
- type RouteIndex
- type Source
- type SourceFunc
- type SourceSpec
- type SourceType
- type Spec
- func Addition() Spec
- func And() Spec
- func Append() Spec
- func BernoulliRandom() Spec
- func Ceil() Spec
- func Close() Spec
- func Cos() Spec
- func Delay() Spec
- func Division() Spec
- func EqualTo() Spec
- func Exp() Spec
- func ExponentialRandom() Spec
- func Exponentiation() Spec
- func First() Spec
- func Floor() Spec
- func Flush() Spec
- func Gate() Spec
- func Get() Spec
- func GreaterThan() Spec
- func HTTPRequest() Spec
- func HasField() Spec
- func HasPrefix() Spec
- func HasSuffix() Spec
- func Head() Spec
- func Identity() Spec
- func InArray() Spec
- func InString() Spec
- func Init() Spec
- func IsArray() Spec
- func IsBoolean() Spec
- func IsError() Spec
- func IsNumber() Spec
- func IsObject() Spec
- func IsString() Spec
- func Keys() Spec
- func Last() Spec
- func Latch() Spec
- func Len() Spec
- func LessThan() Spec
- func Ln() Spec
- func Log() Spec
- func Log10() Spec
- func Merge() Spec
- func Modulation() Spec
- func Multiplication() Spec
- func NSQConsumerConnect() Spec
- func NSQConsumerReceive() Spec
- func NormalRandom() Spec
- func Not() Spec
- func NotEqualTo() Spec
- func Or() Spec
- func ParseJSON() Spec
- func PoissonRandom() Spec
- func Set() Spec
- func Sin() Spec
- func Sink() Spec
- func Sqrt() Spec
- func StdinReceive() Spec
- func StringConcat() Spec
- func StringSplit() Spec
- func Subtraction() Spec
- func Tail() Spec
- func Tan() Spec
- func Timestamp() Spec
- func ToNumber() Spec
- func ToString() Spec
- func UniformRandom() Spec
- func ValueGet() Spec
- func ValueSet() Spec
- func Write() Spec
- func ZipfRandom() Spec
- type Stdin
- type Store
- type Value
Constants ¶
const ( DISCONNECTED = iota CONNECTED )
const ( NONE = iota KEY_VALUE LIST VALUE_PRIMITIVE PRIORITY NSQCONSUMER WSCLIENT STDIN )
Variables ¶
the global random number source
Functions ¶
func GetLibrary ¶
Library is the set of all core block Specs TODO: should just "Build" a global variable so we don't have to iterate over all funcs every time we need the library
func GetSources ¶
func GetSources() map[string]SourceSpec
Types ¶
type Block ¶
type Block struct { Monitor chan MonitorMessage // contains filtered or unexported fields }
A Block describes the block's components
func (*Block) Connect ¶
func (b *Block) Connect(id RouteIndex, c Connection) error
Connect connects a Route, specified by ID, to a connection
func (*Block) Disconnect ¶
func (b *Block) Disconnect(id RouteIndex, c Connection) error
Disconnect removes a connection from a Input
func (*Block) GetInput ¶
func (b *Block) GetInput(id RouteIndex) (Input, error)
GetInput returns the specified Input
func (*Block) GetOutputs ¶
Outputs return a list of manifest pairs for the block
func (*Block) SetInput ¶
func (b *Block) SetInput(id RouteIndex, v *InputValue) error
RouteValue sets the route to always be the specified value
type BlockInfo ¶
type BlockInfo uint8
BlockAlert defines the possible messages a block can emit about its runnig state
func (BlockInfo) MarshalJSON ¶
type BlockRouting ¶
type BlockRouting struct { Inputs []Input Outputs []Output Source Source InterruptChan chan Interrupt sync.RWMutex }
A block's BlockRouting is the set of Input and Output routes, and the Interrupt channel
type BlockState ¶
type BlockState struct { Processed bool // contains filtered or unexported fields }
A block's BlockState is the pair of input/output MessageMaps, and the Manifest
type Input ¶
type Input struct { Name string `json:"name"` Value *InputValue `json:"value"` Type JSONType `json:"type"` C chan Message `json:"-"` }
Input is an inbound route to a block. A Input holds the channel that allows Messages to be passed into the block. A Input's Path is applied to the inbound Message before populating the MessageMap and calling the Kernel. A Input can be set to a Value, instead of waiting for an inbound message.
type InputValue ¶
type InputValue struct {
Data interface{} `json:"data"`
}
func (*InputValue) Exists ¶
func (i *InputValue) Exists() bool
type Interrupt ¶
type Interrupt func() bool
Interrupt is a function that interrupts a running block in order to change its state. If the interrupt returns false, the block will quit.
type JSONType ¶
type JSONType uint8
JSONType defines the possible types that variables in core can take
func (JSONType) MarshalJSON ¶
func (*JSONType) UnmarshalJSON ¶
type Kernel ¶
type Kernel func(MessageMap, MessageMap, MessageMap, Source, chan Interrupt) Interrupt
Kernel is a block's core function that operates on an inbound message. It works by populating the outbound MessageMap, and can be interrupted on its Interrupt channel.
type Manifest ¶
type Manifest map[ManifestPair]struct{}
A block's Manifest is the set of Connections
type ManifestPair ¶
type ManifestPair struct { Connection // contains filtered or unexported fields }
A ManifestPair is a unique reference to an Output/Connection pair
type MessageMap ¶
type MessageMap map[RouteIndex]Message
MessageMap maps a block's inbound routes onto the Messages they contain
type MonitorMessage ¶
type MonitorMessage struct { Type BlockInfo `json:"type"` Data interface{} `json:"data,omitempty"` }
type NSQConsumer ¶
type NSQConsumer struct {
// contains filtered or unexported fields
}
func (NSQConsumer) GetType ¶
func (s NSQConsumer) GetType() SourceType
func (NSQConsumer) HandleMessage ¶
func (s NSQConsumer) HandleMessage(message *nsq.Message) error
func (NSQConsumer) ReceiveMessage ¶
func (s NSQConsumer) ReceiveMessage(i chan Interrupt) (string, Interrupt, error)
func (NSQConsumer) Serve ¶
func (s NSQConsumer) Serve()
func (NSQConsumer) Stop ¶
func (s NSQConsumer) Stop()
type Output ¶
type Output struct { Name string `json:"name"` Type JSONType `json:"type"` Connections map[Connection]struct{} `json:"-"` }
An Output holds a set of Connections. Each Connection refers to a Input.C. Every outbound mesage is sent on every Connection in the Connections set.
type PriorityQueue ¶
func (PriorityQueue) GetType ¶
func (pq PriorityQueue) GetType() SourceType
type RouteIndex ¶
type RouteIndex int
RouteIndex is the index into a MessageMap. The 0th index corresponds to that block's 0th Input or Output
type Source ¶
type Source interface {
GetType() SourceType
}
func NewKeyValue ¶
func NewKeyValue() Source
func NewNSQConsumer ¶
func NewNSQConsumer() Source
func NewPriorityQueue ¶
func NewPriorityQueue() Source
func NewWsClient ¶
func NewWsClient() Source
type SourceSpec ¶
type SourceSpec struct { Name string Type SourceType New SourceFunc Category []string }
A SourceSpec defines a source's name and type
func KeyValueStore ¶
func KeyValueStore() SourceSpec
func ListStore ¶
func ListStore() SourceSpec
func NSQConsumerInterface ¶
func NSQConsumerInterface() SourceSpec
func PriorityQueueStore ¶
func PriorityQueueStore() SourceSpec
func StdinInterface ¶
func StdinInterface() SourceSpec
func ValueStore ¶
func ValueStore() SourceSpec
func WebsocketClient ¶
func WebsocketClient() SourceSpec
type SourceType ¶
type SourceType int
SourceType is used to indicate what kind of source a block can connect to
func (SourceType) MarshalJSON ¶
func (s SourceType) MarshalJSON() ([]byte, error)
func (*SourceType) UnmarshalJSON ¶
func (s *SourceType) UnmarshalJSON(data []byte) error
type Spec ¶
type Spec struct { Name string Category []string Inputs []Pin Outputs []Pin Source SourceType Kernel Kernel }
A Spec defines a block's input and output Pins, and the block's Kernel.
func BernoulliRandom ¶
func BernoulliRandom() Spec
BernoulliRandom emits a draw from a Bernoulli distribution. This block returns a boolean
func ExponentialRandom ¶
func ExponentialRandom() Spec
ExponentialRandom emits an Exponentially distribtued random number
func Exponentiation ¶
func Exponentiation() Spec
Exponentiation returns the base raised to the exponent
func First ¶
func First() Spec
first emits true when it receives its first message, and false otherwise
func GreaterThan ¶
func GreaterThan() Spec
GreaterThan returns true if value[0] > value[1] or false otherwise
func HTTPRequest ¶
func HTTPRequest() Spec
HTTPResponse makes an HTTP request to the specified URL, emitting the response as a string.
func HasField ¶
func HasField() Spec
HasField returns true if the supplied string is a field of the supplied object
func InArray ¶
func InArray() Spec
InArray returns true if the supplied element is in the supplied array
func Latch ¶
func Latch() Spec
Latch emits the inbound message on the 0th output if ctrl is true, and the 1st output if ctrl is false
func LessThan ¶
func LessThan() Spec
LessThan returns true if value[0] < value[1] or false otherwise
func Log ¶
func Log() Spec
Log writes the inbound message to stdout TODO where should this write exactly? TODO there should be a stdout source block and Log should be a compound block with a writer
func Merge ¶
func Merge() Spec
Merge recursively merges two objects, favouring the first input to resolve conflicts
func Modulation ¶
func Modulation() Spec
Modulation returns the remainder of the dividend mod divisor
func Multiplication ¶
func Multiplication() Spec
Multiplication returns the product of the multiplicanda
func NSQConsumerConnect ¶
func NSQConsumerConnect() Spec
func NSQConsumerReceive ¶
func NSQConsumerReceive() Spec
NSQRecieve receives messages from the NSQ system.
OutPin 0: received message
func NormalRandom ¶
func NormalRandom() Spec
NormalRandom emits a normally distributed random number with the supplied mean and variance
func NotEqualTo ¶
func NotEqualTo() Spec
NotEqualTo returns true if value[0] != value[1] or false otherwise
func PoissonRandom ¶
func PoissonRandom() Spec
PoissonRandom emits a Poisson distribtued random number
func StdinReceive ¶
func StdinReceive() Spec
func StringConcat ¶
func StringConcat() Spec
func StringSplit ¶
func StringSplit() Spec
func Subtraction ¶
func Subtraction() Spec
Subtraction returns the difference of the minuend - subtrahend
func ZipfRandom ¶
func ZipfRandom() Spec
ZipfRandom emits a Zipfian distributed random number notation follows the wikipedia page http://en.wikipedia.org/wiki/Zipf%E2%80%93Mandelbrot_law not the golang Zipf parameters
type Stdin ¶
type Stdin struct {
// contains filtered or unexported fields
}
func (Stdin) GetType ¶
func (stdin Stdin) GetType() SourceType
func (Stdin) ReceiveMessage ¶
Source Files ¶
- IO.go
- array_blocks.go
- assertions.go
- block.go
- core_blocks.go
- interface_NSQ.go
- interface_stdin.go
- interface_wsclient.go
- jsontype.go
- library.go
- logic.go
- membership.go
- monads.go
- networkIO.go
- object.go
- parsers.go
- random.go
- sources.go
- store_keyvalue.go
- store_list.go
- store_pq.go
- store_value.go
- strings.go
- time.go
- types.go
- util.go