parts

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package parts contains various pre-made bits and pieces to combine into the graph.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregator

type Aggregator struct {
	Input       string `json:"input"`
	Output      string `json:"output"`
	Aggregation string `json:"aggr"`
	Value       string `json:"value"`
	ValueType   string `json:"value_type"`
	Key         string `json:"key"`
	KeyType     string `json:"key_type"`
}

Aggregator aggregates some expression of input over some keys.

func (*Aggregator) AssociateEditor

func (*Aggregator) AssociateEditor(t *template.Template) error

AssociateEditor associates a template called "part_view" with the given template.

func (*Aggregator) Channels

func (p *Aggregator) Channels() (read, written source.StringSet)

Channels returns any channels used. Anything returned that is not a channel is ignored.

func (*Aggregator) Clone

func (p *Aggregator) Clone() interface{}

Clone returns a copy of this part.

func (*Aggregator) Help

func (*Aggregator) Help() template.HTML

Help returns useful help information.

func (*Aggregator) Impl

func (p *Aggregator) Impl() (head, body, tail string)

Impl returns Go source code implementing the part.

func (*Aggregator) Imports

func (*Aggregator) Imports() []string

Imports returns any extra import lines needed.

func (*Aggregator) RenameChannel

func (p *Aggregator) RenameChannel(from, to string)

RenameChannel renames any uses of the channel "from" to the channel "to".

func (*Aggregator) TypeKey

func (*Aggregator) TypeKey() string

TypeKey returns the string "Aggregator"

func (*Aggregator) Update

func (p *Aggregator) Update(req *http.Request) error

Update sets fields in the part based on info in the given Request.

type Broadcast

type Broadcast struct {
	Input   string   `json:"input"`
	Outputs []string `json:"outputs"`
}

Broadcast sends each input message to every output, closing all the outputs when the input is closed.

func (*Broadcast) AssociateEditor

func (b *Broadcast) AssociateEditor(tmpl *template.Template) error

AssociateEditor adds a "part_view" template to the given template.

func (*Broadcast) Channels

func (b *Broadcast) Channels() (read, written source.StringSet)

Channels returns the names of all channels used by this goroutine.

func (*Broadcast) Clone

func (b *Broadcast) Clone() interface{}

Clone returns a copy of this part.

func (*Broadcast) Help

func (*Broadcast) Help() template.HTML

Help returns useful help information.

func (*Broadcast) Impl

func (b *Broadcast) Impl() (head, body, tail string)

Impl returns the content of a goroutine implementation.

func (*Broadcast) Imports

func (*Broadcast) Imports() []string

Imports returns a nil slice.

func (*Broadcast) RenameChannel

func (b *Broadcast) RenameChannel(from, to string)

RenameChannel renames a channel possibly used by the input or any outputs.

func (*Broadcast) TypeKey

func (*Broadcast) TypeKey() string

TypeKey returns "Broadcast".

func (*Broadcast) Update

func (b *Broadcast) Update(r *http.Request) error

Update sets fields based on the given Request.

type Code

type Code struct {
	Head, Body, Tail string
}

Code is a component containing arbitrary code.

func (*Code) AssociateEditor

func (c *Code) AssociateEditor(tmpl *template.Template) error

AssociateEditor adds a "part_view" template to the given template.

func (*Code) Channels

func (c *Code) Channels() (read, written source.StringSet)

Channels returns nil - all channel usage is expected to be auto extracted.

func (*Code) Clone

func (c *Code) Clone() interface{}

Clone returns a copy of this Code part.

func (*Code) Help

func (*Code) Help() template.HTML

Help returns a helpful explanation.

func (*Code) Impl

func (c *Code) Impl() (Head, Body, Tail string)

Impl returns the implementation of the goroutine.

func (*Code) Imports

func (*Code) Imports() []string

Imports returns a nil slice.

func (*Code) LineCount

func (c *Code) LineCount() struct{ H, B, T int }

LineCount is number of lines in c.Head, c.Body, c.Tail (conveneince function for templates.)

func (*Code) MarshalJSON

func (c *Code) MarshalJSON() ([]byte, error)

MarshalJSON encodes the Code component as JSON.

func (*Code) RenameChannel

func (c *Code) RenameChannel(from, to string)

RenameChannel does fancy footwork to rename the channel in the code, with a side-effect of nicely formatting it. If a rename issue occurs e.g. because the user's code has a syntax error, the rename is aborted and logged.

func (*Code) TypeKey

func (*Code) TypeKey() string

TypeKey returns "Code".

func (*Code) UnmarshalJSON

func (c *Code) UnmarshalJSON(j []byte) error

UnmarshalJSON decodes the Code component from JSON.

func (*Code) Update

func (c *Code) Update(r *http.Request) error

Update sets relevant fields based on the given Request.

type Filter

type Filter struct {
	Input string    `json:"input"`
	Paths []pathway `json:"paths"`
}

Filter tests values from the input and passes it on to one or more outputs based on predicates.

func (*Filter) AssociateEditor

func (f *Filter) AssociateEditor(tmpl *html.Template) error

AssociateEditor adds a "part_view" template to the given template.

func (*Filter) Channels

func (f *Filter) Channels() (read, written source.StringSet)

Channels returns the names of all channels used by this goroutine.

func (*Filter) ChannelsWritten

func (f *Filter) ChannelsWritten() []string

ChannelsWritten is a convenience function for the template: allows closing outputs only once. (More than one close per channel panics.)

func (*Filter) Clone

func (f *Filter) Clone() interface{}

Clone returns a copy of this Filter part.

func (*Filter) Help

func (*Filter) Help() html.HTML

Help returns useful help information.

func (*Filter) Impl

func (f *Filter) Impl() (head, body, tail string)

Impl returns the content of a goroutine implementation.

func (*Filter) Imports

func (*Filter) Imports() []string

Imports returns a nil slice.

func (*Filter) RenameChannel

func (f *Filter) RenameChannel(from, to string)

RenameChannel renames a channel possibly used by the input or any outputs.

func (*Filter) TypeKey

func (*Filter) TypeKey() string

TypeKey returns "Filter".

func (*Filter) Update

func (f *Filter) Update(r *http.Request) error

Update sets fields based on the given Request.

type HTTPServer

type HTTPServer struct {
	Address  string            `json:"address"`
	Handlers map[string]string `json:"handlers"`
	Errors   string            `json:"errors"`
}

HTTPServer is a simple HTTP server that farms out requests to channels of type partlib.HTTPRequest, as defined by the handlers map.

func (*HTTPServer) AssociateEditor

func (*HTTPServer) AssociateEditor(t *template.Template) error

AssociateEditor associates a template called "part_view" with the given template.

func (*HTTPServer) Channels

func (p *HTTPServer) Channels() (read, written source.StringSet)

Channels returns any channels used. Anything returned that is not a channel is ignored.

func (*HTTPServer) Clone

func (p *HTTPServer) Clone() interface{}

Clone returns a copy of this part.

func (*HTTPServer) Help

func (*HTTPServer) Help() template.HTML

Help returns useful help information.

func (*HTTPServer) Impl

func (p *HTTPServer) Impl() (head, body, tail string)

Impl returns Go source code implementing the part.

func (*HTTPServer) Imports

func (*HTTPServer) Imports() []string

Imports returns any extra import lines needed.

func (*HTTPServer) Paths

func (p *HTTPServer) Paths() []struct{ Pattern, Channel string }

Paths returns each handler as a struct. This is for the benefit of the editor template.

func (*HTTPServer) RenameChannel

func (p *HTTPServer) RenameChannel(from, to string)

RenameChannel renames any uses of the channel "from" to the channel "to".

func (*HTTPServer) TypeKey

func (*HTTPServer) TypeKey() string

TypeKey returns the string "HTTPServer"

func (*HTTPServer) Update

func (p *HTTPServer) Update(req *http.Request) error

Update sets fields in the part based on info in the given Request.

type Multiplexer

type Multiplexer struct {
	Inputs []string `json:"inputs"`
	Output string   `json:"output"`
}

Multiplexer reads from N input channels and writes values into a single output channel. All the channels must have the same or compatible types. Once all input channels are closed, the output channel is also closed.

func (*Multiplexer) Channels

func (m *Multiplexer) Channels() (read, written []string)

Channels returns the names of all channels used by this goroutine.

func (*Multiplexer) Impl

func (m *Multiplexer) Impl() string

Impl returns the content of a goroutine implementing the multiplexer.

func (*Multiplexer) Refresh

func (m *Multiplexer) Refresh() error

Refresh refreshes any cached information.

func (*Multiplexer) TypeKey

func (*Multiplexer) TypeKey() string

TypeKey returns "Multiplexer".

type PartTemplate

type PartTemplate struct {
	Something string `json:"something"`
}

PartTemplate is a mostly blank template for a part, to make it easier to write more parts. TODO: Add necessary fields and write a good doc comment.

func (*PartTemplate) AssociateEditor

func (*PartTemplate) AssociateEditor(t *template.Template) error

AssociateEditor associates a template called "part_view" with the given template.

func (*PartTemplate) Channels

func (p *PartTemplate) Channels() (read, written source.StringSet)

Channels returns any channels used. Anything returned that is not a channel is ignored.

func (*PartTemplate) Clone

func (p *PartTemplate) Clone() interface{}

Clone returns a copy of this part.

func (*PartTemplate) Help

func (*PartTemplate) Help() template.HTML

Help returns useful help information.

func (*PartTemplate) Impl

func (p *PartTemplate) Impl() (head, body, tail string)

Impl returns Go source code implementing the part.

func (*PartTemplate) Imports

func (*PartTemplate) Imports() []string

Imports returns any extra import lines needed.

func (*PartTemplate) RenameChannel

func (p *PartTemplate) RenameChannel(from, to string)

RenameChannel renames any uses of the channel "from" to the channel "to".

func (*PartTemplate) TypeKey

func (*PartTemplate) TypeKey() string

TypeKey returns the string "PartTemplate"

func (*PartTemplate) Update

func (p *PartTemplate) Update(req *http.Request) error

Update sets fields in the part based on info in the given Request.

type StaticSend

type StaticSend struct {
	Output string   `json:"output"`
	Items  []string `json:"items"`
}

StaticSend is a mostly blank template for a part, to make it easier to write more parts. TODO: Add necessary fields and write a good doc comment.

func (*StaticSend) AllItems

func (p *StaticSend) AllItems() string

AllItems returns all the Items in a single string.

func (*StaticSend) AssociateEditor

func (*StaticSend) AssociateEditor(t *template.Template) error

AssociateEditor associates a template called "part_view" with the given template.

func (*StaticSend) Channels

func (p *StaticSend) Channels() (read, written source.StringSet)

Channels returns any channels used. Anything returned that is not a channel is ignored.

func (*StaticSend) Clone

func (p *StaticSend) Clone() interface{}

Clone returns a copy of this part.

func (*StaticSend) Help

func (*StaticSend) Help() template.HTML

Help returns useful help information.

func (*StaticSend) Impl

func (p *StaticSend) Impl() (head, body, tail string)

Impl returns Go source code implementing the part.

func (*StaticSend) Imports

func (*StaticSend) Imports() []string

Imports returns any extra import lines needed.

func (*StaticSend) RenameChannel

func (p *StaticSend) RenameChannel(from, to string)

RenameChannel renames any uses of the channel "from" to the channel "to".

func (*StaticSend) TypeKey

func (*StaticSend) TypeKey() string

TypeKey returns the string "StaticSend"

func (*StaticSend) Update

func (p *StaticSend) Update(req *http.Request) error

Update sets fields in the part based on info in the given Request.

type TextFileReader

type TextFileReader struct {
	PathInput string `json:"path_input"`
	Output    string `json:"output"`
	Error     string `json:"errors"`
}

TextFileReader waits for the path of a file to read to arrive, the reads the file, and streams the lines of text to an output channel typed string, closing the output channel when done. If an error occurs, it stops reading and the error is sent to an error channel, which is not closed.

func (*TextFileReader) AssociateEditor

func (r *TextFileReader) AssociateEditor(t *template.Template) error

AssociateEditor associates a template called "part_view" with the given template.

func (*TextFileReader) Channels

func (r *TextFileReader) Channels() (read, written source.StringSet)

Channels returns any channels used. Anything returned that is not a channel is ignored.

func (*TextFileReader) Clone

func (r *TextFileReader) Clone() interface{}

Clone returns a copy of this part.

func (*TextFileReader) Help

func (*TextFileReader) Help() template.HTML

Help returns useful help information.

func (*TextFileReader) Impl

func (r *TextFileReader) Impl() (head, body, tail string)

Impl returns Go source code implementing the part.

func (*TextFileReader) Imports

func (*TextFileReader) Imports() []string

Imports returns any extra import lines needed.

func (*TextFileReader) RenameChannel

func (r *TextFileReader) RenameChannel(from, to string)

RenameChannel renames any uses of the channel "from" to the channel "to".

func (*TextFileReader) TypeKey

func (*TextFileReader) TypeKey() string

TypeKey returns the string "TextFileReader"

func (*TextFileReader) Update

func (r *TextFileReader) Update(req *http.Request) error

Update sets fields in the part based on info in the given Request.

type Unslicer

type Unslicer struct {
	Input  string `json:"input"`
	Output string `json:"output"`
}

Unslicer ranges over items that arrive via the input, and sends them individually to the output.

func (*Unslicer) AssociateEditor

func (*Unslicer) AssociateEditor(t *template.Template) error

AssociateEditor associates a template called "part_view" with the given template.

func (*Unslicer) Channels

func (p *Unslicer) Channels() (read, written source.StringSet)

Channels returns any channels used. Anything returned that is not a channel is ignored.

func (*Unslicer) Clone

func (p *Unslicer) Clone() interface{}

Clone returns a copy of this part.

func (*Unslicer) Help

func (*Unslicer) Help() template.HTML

Help returns useful help information.

func (*Unslicer) Impl

func (p *Unslicer) Impl() (head, body, tail string)

Impl returns Go source code implementing the part.

func (*Unslicer) Imports

func (*Unslicer) Imports() []string

Imports returns any extra import lines needed.

func (*Unslicer) RenameChannel

func (p *Unslicer) RenameChannel(from, to string)

RenameChannel renames any uses of the channel "from" to the channel "to".

func (*Unslicer) TypeKey

func (*Unslicer) TypeKey() string

TypeKey returns the string "Unslicer"

func (*Unslicer) Update

func (p *Unslicer) Update(req *http.Request) error

Update sets fields in the part based on info in the given Request.

Directories

Path Synopsis
Package partlib includes supporting functions for parts.
Package partlib includes supporting functions for parts.

Jump to

Keyboard shortcuts

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