adaptor

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2017 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Adaptors = map[string]Creator{}

Adaptors stores a map of adaptors by name

View Source
var ErrNamespaceMalformed = errors.New("malformed namespace, expected a '.' deliminated string")

ErrNamespaceMalformed represents the error to be returned when an invalid namespace is given.

Functions

func Add

func Add(name string, creator Creator)

Add should be called in init func of adaptor

Types

type Adaptor

type Adaptor interface {
	Start() error
	Listen() error
	Stop() error
}

Adaptor defines the interface that all database connectors and nodes must follow. Start() consumes data from the interface, Listen() listens on a pipe, processes data, and then emits it. Stop() shuts down the adaptor

func CreateAdaptor

func CreateAdaptor(kind, path string, extra Config, p *pipe.Pipe) (adaptor Adaptor, err error)

CreateAdaptor instantiates an adaptor given the adaptor type and the Config. An Adaptor is expected to add themselves to the Adaptors map in the init() func

func init() {
  adaptors.Add("TYPE", func(p *pipe.Pipe, path string, extra adaptors.Config) (adaptors.StopStartListener, error) {
  })
}

and are expected to confirm to the Adaptor interface

type Config

type Config map[string]interface{}

Config is an alias to map[string]interface{} and helps us turn a fuzzy document into a conrete named struct

func (*Config) CompileNamespace

func (c *Config) CompileNamespace() (string, *regexp.Regexp, error)

CompileNamespace split's on the first '.' and then compiles the second portion to use as the msg filter

func (*Config) Construct

func (c *Config) Construct(conf interface{}) error

Construct will Marshal the Config and then Unmarshal it into a named struct the generic map into a proper struct

func (Config) GetString

func (c Config) GetString(key string) string

GetString returns value stored in the config under the given key, or an empty string if the key doesn't exist, or isn't a string value

type Connectable

type Connectable interface {
	Connect() error
}

Connectable defines the interface that adapters should follow to have their connections set on load Connect() allows the adaptor an opportunity to setup connections prior to Start()

type Creator

type Creator func(*pipe.Pipe, string, Config) (Adaptor, error)

Creator defines the init structure for an adaptor

type DbConfig

type DbConfig struct {
	URI       string `json:"uri" doc:"the uri to connect to, in the form mongo://user:password@host.com:8080/database"` // the database uri
	Namespace string `json:"namespace" doc:"mongo namespace to read/write"`                                             // namespace
	Debug     bool   `json:"debug" doc:"display debug information"`                                                     // debug mode
}

DbConfig is a standard typed config struct to use for as general purpose config for most databases.

type Describable

type Describable interface {
	SampleConfig() string
	Description() string
}

Describable defines the interface that all database connectors and nodes must follow in order to support the help functions. SampleConfig() returns an example YAML structure to configure the adaptor Description() provides contextual information for what the adaptor is for

type ErrNotFound

type ErrNotFound struct {
	Name string
}

ErrNotFound gives the details of the failed adaptor

func (ErrNotFound) Error

func (a ErrNotFound) Error() string

type Error

type Error struct {
	Lvl    ErrorLevel
	Err    string
	Path   string
	Record interface{}
}

Error is an error that happened during an adaptor's operation. Error's include both an indication of the severity, Level, as well as a reference to the Record that was in process when the error occurred

func (Error) Error

func (t Error) Error() string

Error returns the error as a string

type ErrorLevel

type ErrorLevel int

ErrorLevel indicated the severity of the error

const (
	NOTICE ErrorLevel = iota
	WARNING
	ERROR
	CRITICAL
)
  • WARNING Todo

Adaptor errors have levels to indicate their severity. CRITICAL errors indicate that the program cannot continue running.

ERROR errors indicate a problem with a specific document or message. a document might not have been applied properly to a source, but the program can continue

WARNING Todo

NOTICE ToDo

Jump to

Keyboard shortcuts

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