adaptor

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

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 Adaptors

func Adaptors() map[string]Adaptor

Adaptors returns an non-initialized adaptor and is best used for doing assertions to see if the Adaptor supports other interfaces

func Add

func Add(name string, creator Creator)

Add should be called in init func of adaptor

func RegisteredAdaptors added in v0.3.0

func RegisteredAdaptors() []string

RegisteredAdaptors returns a slice of the names of every adaptor registered.

Types

type Adaptor

type Adaptor interface {
	Client() (client.Client, error)
	Reader() (client.Reader, error)
	Writer(chan struct{}, *sync.WaitGroup) (client.Writer, error)
}

Adaptor defines the interface which provides functions to create client interfaces

func GetAdaptor added in v0.3.0

func GetAdaptor(name string, conf Config) (Adaptor, error)

GetAdaptor looks up an adaptor by name and then init's it with the provided Config. returns ErrNotFound if the provided name was not registered.

type BaseConfig added in v0.3.0

type BaseConfig struct {
	URI     string `json:"uri"`
	Timeout string `json:"timeout"`
}

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

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) 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() Adaptor

Creator defines the init structure for an adaptor

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 JSON structure to configure the adaptor Description() provides contextual information for what the adaptor is for

type ErrFuncNotSupported added in v0.3.0

type ErrFuncNotSupported struct {
	Name string
	Func string
}

ErrFuncNotSupported should be used for adaptors that do not support a given function defined by the interface.

func (ErrFuncNotSupported) Error added in v0.3.0

func (a ErrFuncNotSupported) Error() string

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
)

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

type Mock added in v0.3.0

type Mock struct {
	BaseConfig
}

Mock can be used for mocking tests that need no functional client interfaces.

func (*Mock) Client added in v0.3.0

func (m *Mock) Client() (client.Client, error)

Client satisfies the V2 interface for providing a client.Client.

func (*Mock) Reader added in v0.3.0

func (m *Mock) Reader() (client.Reader, error)

Reader satisfies the V2 interface for providing a client.Reader.

func (*Mock) Writer added in v0.3.0

func (m *Mock) Writer(chan struct{}, *sync.WaitGroup) (client.Writer, error)

Writer satisfies the V2 interface for providing a client.Writer.

type UnsupportedMock added in v0.3.0

type UnsupportedMock struct {
	BaseConfig
}

UnsupportedMock can be used for mocking tests that need no functional client interfaces.

func (*UnsupportedMock) Client added in v0.3.0

func (m *UnsupportedMock) Client() (client.Client, error)

Client satisfies the V2 interface for providing a client.Client.

func (*UnsupportedMock) Reader added in v0.3.0

func (m *UnsupportedMock) Reader() (client.Reader, error)

Reader satisfies the V2 interface for providing a client.Reader.

func (*UnsupportedMock) Writer added in v0.3.0

func (m *UnsupportedMock) Writer(chan struct{}, *sync.WaitGroup) (client.Writer, error)

Writer satisfies the V2 interface for providing a client.Writer.

Jump to

Keyboard shortcuts

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