Documentation ¶
Index ¶
- Constants
- type Error
- type ErrorCode
- type HashFn
- type Hasher
- type HasherMock
- type InvalidConfigError
- type NewFiltererFn
- type NewPluginerFn
- type NewPluginerer
- type NewPluginererMock
- type NewReceiverFn
- type NewSenderFn
- type NilPluginError
- type NotSupportedError
- type Option
- func WithCommitID(commitID string) Option
- func WithConfig(config interface{}) Option
- func WithFilterHasher(fn HashFn) Option
- func WithName(name string) Option
- func WithNewFilterer(fn NewFiltererFn) Option
- func WithNewPluginer(fn NewPluginerFn) Option
- func WithNewReceiver(fn NewReceiverFn) Option
- func WithNewSender(fn NewSenderFn) Option
- func WithPluginerHasher(fn HashFn) Option
- func WithReceiverHasher(fn HashFn) Option
- func WithSenderHasher(fn HashFn) Option
- func WithVersion(version string) Option
- type OptionError
- type OptionProcessor
- type Plugin
- func (p *Plugin) CommitID() string
- func (p *Plugin) Config() string
- func (p *Plugin) FiltererHash(config interface{}) (string, error)
- func (p *Plugin) Name() string
- func (p *Plugin) NewFilterer(tid tenant.Id, plugin string, name string, config interface{}, ...) (filter.Filterer, error)
- func (p *Plugin) NewPluginer(config interface{}) (Pluginer, error)
- func (p *Plugin) NewReceiver(tid tenant.Id, plugin string, name string, config interface{}, ...) (receiver.Receiver, error)
- func (p *Plugin) NewSender(tid tenant.Id, plugin string, name string, config interface{}, ...) (sender.Sender, error)
- func (p *Plugin) PluginerHash(config interface{}) (string, error)
- func (p *Plugin) ReceiverHash(config interface{}) (string, error)
- func (p *Plugin) SenderHash(config interface{}) (string, error)
- func (p *Plugin) SupportedTypes() bit.Mask
- func (p *Plugin) Version() string
- func (p *Plugin) WithCommitID(commitID string) error
- func (p *Plugin) WithConfig(config interface{}) error
- func (p *Plugin) WithFilterHasher(fn HashFn) error
- func (p *Plugin) WithName(name string) error
- func (p *Plugin) WithNewFilterer(fn NewFiltererFn) error
- func (p *Plugin) WithNewPluginer(fn NewPluginerFn) error
- func (p *Plugin) WithNewReceiver(fn NewReceiverFn) error
- func (p *Plugin) WithNewSender(fn NewSenderFn) error
- func (p *Plugin) WithPluginerHasher(fn HashFn) error
- func (p *Plugin) WithReceiverHasher(fn HashFn) error
- func (p *Plugin) WithSenderHasher(fn HashFn) error
- func (p *Plugin) WithVersion(version string) error
- type Pluginer
- type PluginerMock
- func (mock *PluginerMock) CommitID() string
- func (mock *PluginerMock) CommitIDCalls() []struct{}
- func (mock *PluginerMock) Config() string
- func (mock *PluginerMock) ConfigCalls() []struct{}
- func (mock *PluginerMock) Name() string
- func (mock *PluginerMock) NameCalls() []struct{}
- func (mock *PluginerMock) SupportedTypes() bit.Mask
- func (mock *PluginerMock) SupportedTypesCalls() []struct{}
- func (mock *PluginerMock) Version() string
- func (mock *PluginerMock) VersionCalls() []struct{}
Constants ¶
const ( TypePluginer bit.Mask = 1 << iota TypeReceiver TypeSender TypeFilter )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
Error wraps a plugin's errors. Because this package will have no knowledge of which plugins it's importing, the convention is for the plugin to set a Code associated with the plugin.
func (*Error) Error ¶
Error implements the standard error interface.
Output:
plugin error (code=42): wrapped Err.Error() goes here
type ErrorCode ¶
type ErrorCode int
ErrorCode holds a numeric value that can be used to communicate an enumerated list of error codes back to the caller. It is expected that the user of the plugin will reference the plugin documentation to determine the meaning of the error.
type Hasher ¶
type Hasher interface { // PluginerHash calculates the hash of a receiver based on the // given configuration PluginerHash(config interface{}) (string, error) }
Hasher defines the hashing interface that a pluginer needs to implement
type HasherMock ¶
type HasherMock struct { // PluginerHashFunc mocks the PluginerHash method. PluginerHashFunc func(config interface{}) (string, error) // contains filtered or unexported fields }
HasherMock is a mock implementation of Hasher.
func TestSomethingThatUsesHasher(t *testing.T) { // make and configure a mocked Hasher mockedHasher := &HasherMock{ PluginerHashFunc: func(config interface{}) (string, error) { panic("mock out the PluginerHash method") }, } // use mockedHasher in code that requires Hasher // and then make assertions. }
func (*HasherMock) PluginerHash ¶
func (mock *HasherMock) PluginerHash(config interface{}) (string, error)
PluginerHash calls PluginerHashFunc.
func (*HasherMock) PluginerHashCalls ¶
func (mock *HasherMock) PluginerHashCalls() []struct { Config interface{} }
PluginerHashCalls gets all the calls that were made to PluginerHash. Check the length with:
len(mockedHasher.PluginerHashCalls())
type InvalidConfigError ¶
type InvalidConfigError struct {
Err error
}
InvalidConfigError is returned when a configuration parameter results in a plugin error
func (*InvalidConfigError) Error ¶
func (e *InvalidConfigError) Error() string
Error implements the standard error interface. It'll display the code as well printing out the Values in key sorted order.
func (*InvalidConfigError) Is ¶
func (e *InvalidConfigError) Is(target error) bool
Is compares two Error. It does a simple string comparison. This means that references to memory at different addresses for the same key will result in different strings, thus causing `Is` to return false.
func (*InvalidConfigError) Unwrap ¶
func (e *InvalidConfigError) Unwrap() error
Unwrap implement's Go v1.13's error pattern
type NewFiltererFn ¶
type NewPluginerFn ¶
type NewPluginerer ¶
NewPluginerer is something that is able to return a new Pluginer
type NewPluginererMock ¶
type NewPluginererMock struct { // NewPluginerFunc mocks the NewPluginer method. NewPluginerFunc func(config interface{}) (Pluginer, error) // PluginerHashFunc mocks the PluginerHash method. PluginerHashFunc func(config interface{}) (string, error) // contains filtered or unexported fields }
NewPluginererMock is a mock implementation of NewPluginerer.
func TestSomethingThatUsesNewPluginerer(t *testing.T) { // make and configure a mocked NewPluginerer mockedNewPluginerer := &NewPluginererMock{ NewPluginerFunc: func(config interface{}) (Pluginer, error) { panic("mock out the NewPluginer method") }, PluginerHashFunc: func(config interface{}) (string, error) { panic("mock out the PluginerHash method") }, } // use mockedNewPluginerer in code that requires NewPluginerer // and then make assertions. }
func (*NewPluginererMock) NewPluginer ¶
func (mock *NewPluginererMock) NewPluginer(config interface{}) (Pluginer, error)
NewPluginer calls NewPluginerFunc.
func (*NewPluginererMock) NewPluginerCalls ¶
func (mock *NewPluginererMock) NewPluginerCalls() []struct { Config interface{} }
NewPluginerCalls gets all the calls that were made to NewPluginer. Check the length with:
len(mockedNewPluginerer.NewPluginerCalls())
func (*NewPluginererMock) PluginerHash ¶
func (mock *NewPluginererMock) PluginerHash(config interface{}) (string, error)
PluginerHash calls PluginerHashFunc.
func (*NewPluginererMock) PluginerHashCalls ¶
func (mock *NewPluginererMock) PluginerHashCalls() []struct { Config interface{} }
PluginerHashCalls gets all the calls that were made to PluginerHash. Check the length with:
len(mockedNewPluginerer.PluginerHashCalls())
type NewReceiverFn ¶
type NewSenderFn ¶
type NilPluginError ¶
type NilPluginError struct{}
func (*NilPluginError) Error ¶
func (e *NilPluginError) Error() string
type NotSupportedError ¶
type NotSupportedError struct{}
NotSupportedError can be returned if a plugin doesn't support publishing subscribing.
func (*NotSupportedError) Error ¶
func (e *NotSupportedError) Error() string
Error implements the standard error interface. It'll display the code as well printing out the Values in key sorted order.
func (*NotSupportedError) Is ¶
func (e *NotSupportedError) Is(target error) bool
Is compares two Error. It does a simple string comparison. This means that references to memory at different addresses for the same key will result in different strings, thus causing `Is` to return false.
type Option ¶
type Option func(OptionProcessor) error
func WithCommitID ¶
func WithConfig ¶
func WithConfig(config interface{}) Option
func WithFilterHasher ¶
func WithNewFilterer ¶
func WithNewFilterer(fn NewFiltererFn) Option
func WithNewPluginer ¶
func WithNewPluginer(fn NewPluginerFn) Option
func WithNewReceiver ¶
func WithNewReceiver(fn NewReceiverFn) Option
func WithNewSender ¶
func WithNewSender(fn NewSenderFn) Option
func WithPluginerHasher ¶
func WithReceiverHasher ¶
func WithSenderHasher ¶
func WithVersion ¶
type OptionError ¶
type OptionError struct {
Err error
}
type OptionProcessor ¶
type OptionProcessor interface { WithName(name string) error WithVersion(version string) error WithCommitID(commitID string) error WithConfig(config interface{}) error WithNewPluginer(fn NewPluginerFn) error WithPluginerHasher(fn HashFn) error // TODO: https://github.com/xmidt-org/ears/issues/74 WithNewFilterer(fn NewFiltererFn) error WithFilterHasher(fn HashFn) error WithNewReceiver(fn NewReceiverFn) error WithReceiverHasher(fn HashFn) error WithNewSender(fn NewSenderFn) error WithSenderHasher(fn HashFn) error }
type Plugin ¶
Plugin implements Pluginer
func (*Plugin) FiltererHash ¶
func (*Plugin) NewFilterer ¶
func (*Plugin) NewPluginer ¶
func (*Plugin) NewReceiver ¶
func (*Plugin) PluginerHash ¶
func (*Plugin) ReceiverHash ¶
func (*Plugin) SenderHash ¶
func (*Plugin) SupportedTypes ¶
func (*Plugin) WithCommitID ¶
func (*Plugin) WithConfig ¶
func (*Plugin) WithFilterHasher ¶
func (*Plugin) WithNewFilterer ¶
func (p *Plugin) WithNewFilterer(fn NewFiltererFn) error
func (*Plugin) WithNewPluginer ¶
func (p *Plugin) WithNewPluginer(fn NewPluginerFn) error
func (*Plugin) WithNewReceiver ¶
func (p *Plugin) WithNewReceiver(fn NewReceiverFn) error
func (*Plugin) WithNewSender ¶
func (p *Plugin) WithNewSender(fn NewSenderFn) error
func (*Plugin) WithPluginerHasher ¶
func (*Plugin) WithReceiverHasher ¶
func (*Plugin) WithSenderHasher ¶
func (*Plugin) WithVersion ¶
type Pluginer ¶
type Pluginer interface { Name() string Version() string CommitID() string Config() string // A bitmask of supported types SupportedTypes() bit.Mask }
Pluginer defines values that should be returned in order to get visibility into which plugin was loaded and how it was configured.
type PluginerMock ¶
type PluginerMock struct { // CommitIDFunc mocks the CommitID method. CommitIDFunc func() string // ConfigFunc mocks the Config method. ConfigFunc func() string // NameFunc mocks the Name method. NameFunc func() string // SupportedTypesFunc mocks the SupportedTypes method. SupportedTypesFunc func() bit.Mask // VersionFunc mocks the Version method. VersionFunc func() string // contains filtered or unexported fields }
PluginerMock is a mock implementation of Pluginer.
func TestSomethingThatUsesPluginer(t *testing.T) { // make and configure a mocked Pluginer mockedPluginer := &PluginerMock{ CommitIDFunc: func() string { panic("mock out the CommitID method") }, ConfigFunc: func() string { panic("mock out the Config method") }, NameFunc: func() string { panic("mock out the Name method") }, SupportedTypesFunc: func() bit.Mask { panic("mock out the SupportedTypes method") }, VersionFunc: func() string { panic("mock out the Version method") }, } // use mockedPluginer in code that requires Pluginer // and then make assertions. }
func (*PluginerMock) CommitID ¶
func (mock *PluginerMock) CommitID() string
CommitID calls CommitIDFunc.
func (*PluginerMock) CommitIDCalls ¶
func (mock *PluginerMock) CommitIDCalls() []struct { }
CommitIDCalls gets all the calls that were made to CommitID. Check the length with:
len(mockedPluginer.CommitIDCalls())
func (*PluginerMock) ConfigCalls ¶
func (mock *PluginerMock) ConfigCalls() []struct { }
ConfigCalls gets all the calls that were made to Config. Check the length with:
len(mockedPluginer.ConfigCalls())
func (*PluginerMock) NameCalls ¶
func (mock *PluginerMock) NameCalls() []struct { }
NameCalls gets all the calls that were made to Name. Check the length with:
len(mockedPluginer.NameCalls())
func (*PluginerMock) SupportedTypes ¶
func (mock *PluginerMock) SupportedTypes() bit.Mask
SupportedTypes calls SupportedTypesFunc.
func (*PluginerMock) SupportedTypesCalls ¶
func (mock *PluginerMock) SupportedTypesCalls() []struct { }
SupportedTypesCalls gets all the calls that were made to SupportedTypes. Check the length with:
len(mockedPluginer.SupportedTypesCalls())
func (*PluginerMock) Version ¶
func (mock *PluginerMock) Version() string
Version calls VersionFunc.
func (*PluginerMock) VersionCalls ¶
func (mock *PluginerMock) VersionCalls() []struct { }
VersionCalls gets all the calls that were made to Version. Check the length with:
len(mockedPluginer.VersionCalls())