Documentation ¶
Index ¶
- func NewEntity(id, name string) *entity
- type Entity
- type EntityNamer
- type EventDispatcher
- type EventPayload
- type IDer
- type IEvent
- type IEventDispatcher
- type IEventHandler
- type IEventPublisher
- type IEventSubscriber
- type MockIEventDispatcher
- type MockIEventHandler
- type MockIEventPublisher
- type MockIEventSubscriber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Entity ¶
type Entity interface { IDer EntityNamer }
type EntityNamer ¶
type EntityNamer interface {
EntityName() string
}
type EventDispatcher ¶
type EventDispatcher[T IEvent] struct { // contains filtered or unexported fields }
container of all the event handler
func (*EventDispatcher[T]) Publish ¶
func (d *EventDispatcher[T]) Publish(ctx context.Context, events ...T) (err error)
func (*EventDispatcher[T]) Subscribe ¶
func (d *EventDispatcher[T]) Subscribe(handler IEventHandler[T], events ...string)
type EventPayload ¶
type EventPayload interface{}
type IEvent ¶
type IEvent interface { IDer EventName() string Payload() EventPayload OccurredAt() time.Time }
func NewEvent ¶
func NewEvent(name string, payload EventPayload) IEvent
type IEventDispatcher ¶
type IEventDispatcher[T IEvent] interface { IEventPublisher[T] IEventSubscriber[T] }
dispatcher needs to subscribe and publish both. he can control the event flow with business logic
func NewEventDispatcher ¶
func NewEventDispatcher[T IEvent]() IEventDispatcher[T]
type IEventHandler ¶
type IEventPublisher ¶
type IEventSubscriber ¶
type IEventSubscriber[T IEvent] interface { Subscribe(handler IEventHandler[T], events ...string) }
type MockIEventDispatcher ¶
MockIEventDispatcher is an autogenerated mock type for the IEventDispatcher type
func NewMockIEventDispatcher ¶
func NewMockIEventDispatcher[T IEvent](t interface { mock.TestingT Cleanup(func()) }) *MockIEventDispatcher[T]
NewMockIEventDispatcher creates a new instance of MockIEventDispatcher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockIEventDispatcher[T]) Publish ¶
func (_m *MockIEventDispatcher[T]) Publish(ctx context.Context, events ...T) error
Publish provides a mock function with given fields: ctx, events
func (*MockIEventDispatcher[T]) Subscribe ¶
func (_m *MockIEventDispatcher[T]) Subscribe(handler IEventHandler[T], events ...string)
Subscribe provides a mock function with given fields: handler, events
type MockIEventHandler ¶
MockIEventHandler is an autogenerated mock type for the IEventHandler type
func NewMockIEventHandler ¶
func NewMockIEventHandler[T IEvent](t interface { mock.TestingT Cleanup(func()) }) *MockIEventHandler[T]
NewMockIEventHandler creates a new instance of MockIEventHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockIEventHandler[T]) HandleEvent ¶
func (_m *MockIEventHandler[T]) HandleEvent(ctx context.Context, event T) error
HandleEvent provides a mock function with given fields: ctx, event
type MockIEventPublisher ¶
MockIEventPublisher is an autogenerated mock type for the IEventPublisher type
func NewMockIEventPublisher ¶
func NewMockIEventPublisher[T IEvent](t interface { mock.TestingT Cleanup(func()) }) *MockIEventPublisher[T]
NewMockIEventPublisher creates a new instance of MockIEventPublisher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
type MockIEventSubscriber ¶
MockIEventSubscriber is an autogenerated mock type for the IEventSubscriber type
func NewMockIEventSubscriber ¶
func NewMockIEventSubscriber[T IEvent](t interface { mock.TestingT Cleanup(func()) }) *MockIEventSubscriber[T]
NewMockIEventSubscriber creates a new instance of MockIEventSubscriber. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockIEventSubscriber[T]) Subscribe ¶
func (_m *MockIEventSubscriber[T]) Subscribe(handler IEventHandler[T], events ...string)
Subscribe provides a mock function with given fields: handler, events