receiver

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hasher

type Hasher interface {
	// ReceiverHash calculates the hash of a receiver based on the
	// given configuration
	ReceiverHash(config interface{}) (string, error)
}

Hasher defines the hashing interface that a receiver needs to implement

type HasherMock

type HasherMock struct {
	// ReceiverHashFunc mocks the ReceiverHash method.
	ReceiverHashFunc 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{
		ReceiverHashFunc: func(config interface{}) (string, error) {
			panic("mock out the ReceiverHash method")
		},
	}

	// use mockedHasher in code that requires Hasher
	// and then make assertions.

}

func (*HasherMock) ReceiverHash

func (mock *HasherMock) ReceiverHash(config interface{}) (string, error)

ReceiverHash calls ReceiverHashFunc.

func (*HasherMock) ReceiverHashCalls

func (mock *HasherMock) ReceiverHashCalls() []struct {
	Config interface{}
}

ReceiverHashCalls gets all the calls that were made to ReceiverHash. Check the length with:

len(mockedHasher.ReceiverHashCalls())

type InvalidConfigError

type InvalidConfigError struct {
	Err error
}

InvalidConfigError is returned when a bad configuration is passed into the New* functions

func (*InvalidConfigError) Error

func (e *InvalidConfigError) Error() string

func (*InvalidConfigError) Unwrap

func (e *InvalidConfigError) Unwrap() error

type NewReceiverer

type NewReceiverer interface {
	Hasher
	// NewReceiver returns an object that implements the
	// Receiver interface
	NewReceiver(tid tenant.Id, plugin string, name string, config interface{}, secrets secret.Vault, tableSyncer syncer.DeltaSyncer) (Receiver, error)
}

type NewReceivererMock

type NewReceivererMock struct {
	// NewReceiverFunc mocks the NewReceiver method.
	NewReceiverFunc func(tid tenant.Id, plugin string, name string, config interface{}, secrets secret.Vault, tableSyncer syncer.DeltaSyncer) (Receiver, error)

	// ReceiverHashFunc mocks the ReceiverHash method.
	ReceiverHashFunc func(config interface{}) (string, error)
	// contains filtered or unexported fields
}

NewReceivererMock is a mock implementation of NewReceiverer.

func TestSomethingThatUsesNewReceiverer(t *testing.T) {

	// make and configure a mocked NewReceiverer
	mockedNewReceiverer := &NewReceivererMock{
		NewReceiverFunc: func(tid tenant.Id, plugin string, name string, config interface{}, secrets secret.Vault) (Receiver, error) {
			panic("mock out the NewReceiver method")
		},
		ReceiverHashFunc: func(config interface{}) (string, error) {
			panic("mock out the ReceiverHash method")
		},
	}

	// use mockedNewReceiverer in code that requires NewReceiverer
	// and then make assertions.

}

func (*NewReceivererMock) NewReceiver

func (mock *NewReceivererMock) NewReceiver(tid tenant.Id, plugin string, name string, config interface{}, secrets secret.Vault, tableSyncer syncer.DeltaSyncer) (Receiver, error)

NewReceiver calls NewReceiverFunc.

func (*NewReceivererMock) NewReceiverCalls

func (mock *NewReceivererMock) NewReceiverCalls() []struct {
	Tid     tenant.Id
	Plugin  string
	Name    string
	Config  interface{}
	Secrets secret.Vault
}

NewReceiverCalls gets all the calls that were made to NewReceiver. Check the length with:

len(mockedNewReceiverer.NewReceiverCalls())

func (*NewReceivererMock) ReceiverHash

func (mock *NewReceivererMock) ReceiverHash(config interface{}) (string, error)

ReceiverHash calls ReceiverHashFunc.

func (*NewReceivererMock) ReceiverHashCalls

func (mock *NewReceivererMock) ReceiverHashCalls() []struct {
	Config interface{}
}

ReceiverHashCalls gets all the calls that were made to ReceiverHash. Check the length with:

len(mockedNewReceiverer.ReceiverHashCalls())

type NextFn

type NextFn func(e event.Event)

NextFn defines the signature of a function that can take in an event and process it

type Receiver

type Receiver interface {
	Receive(next NextFn) error
	// StopReceiving will stop the receiver from receiving events.
	// This will cause Receive to return.
	StopReceiving(ctx context.Context) error
	// Send a test event into the route
	Trigger(e event.Event)
	//
	Config() interface{}
	Name() string
	Plugin() string
	Tenant() tenant.Id
	EventSuccessCount() int
	EventSuccessVelocity() int
	EventErrorCount() int
	EventErrorVelocity() int
	EventTs() int64
	LogSuccess()
}

Receiver is a plugin that will receive messages and will send them to `NextFn`

type ReceiverMock

type ReceiverMock struct {
	// ConfigFunc mocks the Config method.
	ConfigFunc func() interface{}

	// NameFunc mocks the Name method.
	NameFunc func() string

	// PluginFunc mocks the Plugin method.
	PluginFunc func() string

	// ReceiveFunc mocks the Receive method.
	ReceiveFunc func(next NextFn) error

	// StopReceivingFunc mocks the StopReceiving method.
	StopReceivingFunc func(ctx context.Context) error

	// TenantFunc mocks the Tenant method.
	TenantFunc func() tenant.Id

	// TriggerFunc mocks the Trigger method.
	TriggerFunc func(e event.Event)
	// contains filtered or unexported fields
}

ReceiverMock is a mock implementation of Receiver.

func TestSomethingThatUsesReceiver(t *testing.T) {

	// make and configure a mocked Receiver
	mockedReceiver := &ReceiverMock{
		ConfigFunc: func() interface{} {
			panic("mock out the Config method")
		},
		NameFunc: func() string {
			panic("mock out the Name method")
		},
		PluginFunc: func() string {
			panic("mock out the Plugin method")
		},
		ReceiveFunc: func(next NextFn) error {
			panic("mock out the Receive method")
		},
		StopReceivingFunc: func(ctx context.Context) error {
			panic("mock out the StopReceiving method")
		},
		TenantFunc: func() tenant.Id {
			panic("mock out the Tenant method")
		},
		TriggerFunc: func(e event.Event)  {
			panic("mock out the Trigger method")
		},
	}

	// use mockedReceiver in code that requires Receiver
	// and then make assertions.

}

func (*ReceiverMock) Config added in v0.2.1

func (mock *ReceiverMock) Config() interface{}

Config calls ConfigFunc.

func (*ReceiverMock) ConfigCalls added in v0.2.1

func (mock *ReceiverMock) ConfigCalls() []struct {
}

ConfigCalls gets all the calls that were made to Config. Check the length with:

len(mockedReceiver.ConfigCalls())

func (*ReceiverMock) EventErrorCount added in v1.1.2

func (mock *ReceiverMock) EventErrorCount() int

func (*ReceiverMock) EventErrorVelocity added in v1.1.2

func (mock *ReceiverMock) EventErrorVelocity() int

func (*ReceiverMock) EventSuccessCount added in v1.1.2

func (mock *ReceiverMock) EventSuccessCount() int

func (*ReceiverMock) EventSuccessVelocity added in v1.1.2

func (mock *ReceiverMock) EventSuccessVelocity() int

func (*ReceiverMock) EventTs added in v1.1.2

func (mock *ReceiverMock) EventTs() int64

func (*ReceiverMock) LogSuccess added in v1.1.2

func (mock *ReceiverMock) LogSuccess()

func (*ReceiverMock) Name added in v0.2.1

func (mock *ReceiverMock) Name() string

Name calls NameFunc.

func (*ReceiverMock) NameCalls added in v0.2.1

func (mock *ReceiverMock) NameCalls() []struct {
}

NameCalls gets all the calls that were made to Name. Check the length with:

len(mockedReceiver.NameCalls())

func (*ReceiverMock) Plugin added in v0.2.1

func (mock *ReceiverMock) Plugin() string

Plugin calls PluginFunc.

func (*ReceiverMock) PluginCalls added in v0.2.1

func (mock *ReceiverMock) PluginCalls() []struct {
}

PluginCalls gets all the calls that were made to Plugin. Check the length with:

len(mockedReceiver.PluginCalls())

func (*ReceiverMock) Receive

func (mock *ReceiverMock) Receive(next NextFn) error

Receive calls ReceiveFunc.

func (*ReceiverMock) ReceiveCalls

func (mock *ReceiverMock) ReceiveCalls() []struct {
	Next NextFn
}

ReceiveCalls gets all the calls that were made to Receive. Check the length with:

len(mockedReceiver.ReceiveCalls())

func (*ReceiverMock) StopReceiving

func (mock *ReceiverMock) StopReceiving(ctx context.Context) error

StopReceiving calls StopReceivingFunc.

func (*ReceiverMock) StopReceivingCalls

func (mock *ReceiverMock) StopReceivingCalls() []struct {
	Ctx context.Context
}

StopReceivingCalls gets all the calls that were made to StopReceiving. Check the length with:

len(mockedReceiver.StopReceivingCalls())

func (*ReceiverMock) Tenant added in v0.3.0

func (mock *ReceiverMock) Tenant() tenant.Id

Tenant calls TenantFunc.

func (*ReceiverMock) TenantCalls added in v0.3.0

func (mock *ReceiverMock) TenantCalls() []struct {
}

TenantCalls gets all the calls that were made to Tenant. Check the length with:

len(mockedReceiver.TenantCalls())

func (*ReceiverMock) Trigger added in v1.1.0

func (mock *ReceiverMock) Trigger(e event.Event)

Trigger calls TriggerFunc.

func (*ReceiverMock) TriggerCalls added in v1.1.0

func (mock *ReceiverMock) TriggerCalls() []struct {
	E event.Event
}

TriggerCalls gets all the calls that were made to Trigger. Check the length with:

len(mockedReceiver.TriggerCalls())

Jump to

Keyboard shortcuts

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