Documentation ¶
Index ¶
- Constants
- type Event
- type EventMock
- func (mock *EventMock) Ack()
- func (mock *EventMock) AckCalls() []struct{}
- func (mock *EventMock) Clone(ctx context.Context) (Event, error)
- func (mock *EventMock) CloneCalls() []struct{ ... }
- func (mock *EventMock) Context() context.Context
- func (mock *EventMock) ContextCalls() []struct{}
- func (mock *EventMock) GetPathValue(path string) (interface{}, interface{}, string)
- func (mock *EventMock) GetPathValueCalls() []struct{ ... }
- func (mock *EventMock) Metadata() interface{}
- func (mock *EventMock) MetadataCalls() []struct{}
- func (mock *EventMock) Nack(err error)
- func (mock *EventMock) NackCalls() []struct{ ... }
- func (mock *EventMock) Payload() interface{}
- func (mock *EventMock) PayloadCalls() []struct{}
- func (mock *EventMock) SetContext(ctx context.Context) error
- func (mock *EventMock) SetContextCalls() []struct{ ... }
- func (mock *EventMock) SetMetadata(metadata interface{}) error
- func (mock *EventMock) SetMetadataCalls() []struct{ ... }
- func (mock *EventMock) SetPathValue(path string, val interface{}, createPath bool) (interface{}, string)
- func (mock *EventMock) SetPathValueCalls() []struct{ ... }
- func (mock *EventMock) SetPayload(payload interface{}) error
- func (mock *EventMock) SetPayloadCalls() []struct{ ... }
- type EventOption
- type NoAckHandlersError
Constants ¶
const ( PAYLOAD = "payload" METADATA = "metadata" TRACE = "trace" TENANT = "tenant" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event interface { //Get the event payload Payload() interface{} //Get the event metadata Metadata() interface{} //Get the event context Context() context.Context //Set the event payload //Will return an error if the event is done SetPayload(payload interface{}) error //Set the event metadata //Will return an error if the event is done SetMetadata(metadata interface{}) error // SetPathValue sets object value at path in either payload or metadata and returns its parent // object and parent key if those exist SetPathValue(path string, val interface{}, createPath bool) (interface{}, string) // GetPathValue finds object at path in either payload or metadata and returns such object // if one exists along with its parent object and parent key if those exist GetPathValue(path string) (interface{}, interface{}, string) //Replace the current event context //Will return an error if the event is done SetContext(ctx context.Context) error //Acknowledge that the event is handled successfully //Further actions on the event are no longer possible Ack() //Acknowledge that there is an error handling the event //Further actions on the event are no longer possible Nack(err error) //Create a child the event with payload deep-copied //Clone fails and return an error if the event is already acknowledged Clone(ctx context.Context) (Event, error) }
type EventMock ¶
type EventMock struct { // AckFunc mocks the Ack method. AckFunc func() // CloneFunc mocks the Clone method. CloneFunc func(ctx context.Context) (Event, error) // ContextFunc mocks the Context method. ContextFunc func() context.Context // GetPathValueFunc mocks the GetPathValue method. GetPathValueFunc func(path string) (interface{}, interface{}, string) // MetadataFunc mocks the Metadata method. MetadataFunc func() interface{} // NackFunc mocks the Nack method. NackFunc func(err error) // PayloadFunc mocks the Payload method. PayloadFunc func() interface{} // SetContextFunc mocks the SetContext method. SetContextFunc func(ctx context.Context) error // SetMetadataFunc mocks the SetMetadata method. SetMetadataFunc func(metadata interface{}) error // SetPathValueFunc mocks the SetPathValue method. SetPathValueFunc func(path string, val interface{}, createPath bool) (interface{}, string) // SetPayloadFunc mocks the SetPayload method. SetPayloadFunc func(payload interface{}) error // contains filtered or unexported fields }
EventMock is a mock implementation of Event.
func TestSomethingThatUsesEvent(t *testing.T) { // make and configure a mocked Event mockedEvent := &EventMock{ AckFunc: func() { panic("mock out the Ack method") }, CloneFunc: func(ctx context.Context) (Event, error) { panic("mock out the Clone method") }, ContextFunc: func() context.Context { panic("mock out the Context method") }, GetPathValueFunc: func(path string) (interface{}, interface{}, string) { panic("mock out the GetPathValue method") }, MetadataFunc: func() interface{} { panic("mock out the Metadata method") }, NackFunc: func(err error) { panic("mock out the Nack method") }, PayloadFunc: func() interface{} { panic("mock out the Payload method") }, SetContextFunc: func(ctx context.Context) error { panic("mock out the SetContext method") }, SetMetadataFunc: func(metadata interface{}) error { panic("mock out the SetMetadata method") }, SetPathValueFunc: func(path string, val interface{}, createPath bool) (interface{}, string) { panic("mock out the SetPathValue method") }, SetPayloadFunc: func(payload interface{}) error { panic("mock out the SetPayload method") }, } // use mockedEvent in code that requires Event // and then make assertions. }
func (*EventMock) AckCalls ¶
func (mock *EventMock) AckCalls() []struct { }
AckCalls gets all the calls that were made to Ack. Check the length with:
len(mockedEvent.AckCalls())
func (*EventMock) CloneCalls ¶
CloneCalls gets all the calls that were made to Clone. Check the length with:
len(mockedEvent.CloneCalls())
func (*EventMock) ContextCalls ¶
func (mock *EventMock) ContextCalls() []struct { }
ContextCalls gets all the calls that were made to Context. Check the length with:
len(mockedEvent.ContextCalls())
func (*EventMock) GetPathValue ¶
GetPathValue calls GetPathValueFunc.
func (*EventMock) GetPathValueCalls ¶
GetPathValueCalls gets all the calls that were made to GetPathValue. Check the length with:
len(mockedEvent.GetPathValueCalls())
func (*EventMock) Metadata ¶
func (mock *EventMock) Metadata() interface{}
Metadata calls MetadataFunc.
func (*EventMock) MetadataCalls ¶
func (mock *EventMock) MetadataCalls() []struct { }
MetadataCalls gets all the calls that were made to Metadata. Check the length with:
len(mockedEvent.MetadataCalls())
func (*EventMock) NackCalls ¶
NackCalls gets all the calls that were made to Nack. Check the length with:
len(mockedEvent.NackCalls())
func (*EventMock) PayloadCalls ¶
func (mock *EventMock) PayloadCalls() []struct { }
PayloadCalls gets all the calls that were made to Payload. Check the length with:
len(mockedEvent.PayloadCalls())
func (*EventMock) SetContext ¶
SetContext calls SetContextFunc.
func (*EventMock) SetContextCalls ¶
SetContextCalls gets all the calls that were made to SetContext. Check the length with:
len(mockedEvent.SetContextCalls())
func (*EventMock) SetMetadata ¶
SetMetadata calls SetMetadataFunc.
func (*EventMock) SetMetadataCalls ¶
func (mock *EventMock) SetMetadataCalls() []struct { Metadata interface{} }
SetMetadataCalls gets all the calls that were made to SetMetadata. Check the length with:
len(mockedEvent.SetMetadataCalls())
func (*EventMock) SetPathValue ¶
func (mock *EventMock) SetPathValue(path string, val interface{}, createPath bool) (interface{}, string)
SetPathValue calls SetPathValueFunc.
func (*EventMock) SetPathValueCalls ¶
SetPathValueCalls gets all the calls that were made to SetPathValue. Check the length with:
len(mockedEvent.SetPathValueCalls())
func (*EventMock) SetPayload ¶
SetPayload calls SetPayloadFunc.
func (*EventMock) SetPayloadCalls ¶
func (mock *EventMock) SetPayloadCalls() []struct { Payload interface{} }
SetPayloadCalls gets all the calls that were made to SetPayload. Check the length with:
len(mockedEvent.SetPayloadCalls())
type EventOption ¶
type EventOption func(*event) error
func FailOnAck ¶
func FailOnAck(t *testing.T) EventOption
func FailOnNack ¶
func FailOnNack(t *testing.T) EventOption
func WithAck ¶
func WithAck(handledFn func(Event), errFn func(Event, error)) EventOption
event acknowledge option with two completion functions, handledFn and errFn. An event with acknowledgement option will be notified through the handledFn when an event is handled, or through the errFn when there is an error handling it. An event is considered handled when it and all its child events (derived from the Clone function) have called the Ack function. An event is considered to have an error if it or any of its child events (derived from the Clone function) has called the Nack function. An event can also error out if it does not receive all the acknowledgements before the context timeout/cancellation.
func WithMetadata ¶
func WithMetadata(metadata interface{}) EventOption
type NoAckHandlersError ¶
type NoAckHandlersError struct { }
func (*NoAckHandlersError) Error ¶
func (e *NoAckHandlersError) Error() string