ddd

package
v0.0.0-...-8991645 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEntity

func NewEntity(id, name string) *entity

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 IDer

type IDer interface {
	ID() string
}

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 IEventHandler[T IEvent] interface {
	HandleEvent(ctx context.Context, event T) error
}

type IEventPublisher

type IEventPublisher[T IEvent] interface {
	Publish(ctx context.Context, events ...T) error
}

type IEventSubscriber

type IEventSubscriber[T IEvent] interface {
	Subscribe(handler IEventHandler[T], events ...string)
}

type MockIEventDispatcher

type MockIEventDispatcher[T IEvent] struct {
	mock.Mock
}

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

type MockIEventHandler[T IEvent] struct {
	mock.Mock
}

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

type MockIEventPublisher[T IEvent] struct {
	mock.Mock
}

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.

func (*MockIEventPublisher[T]) Publish

func (_m *MockIEventPublisher[T]) Publish(ctx context.Context, events ...T) error

Publish provides a mock function with given fields: ctx, events

type MockIEventSubscriber

type MockIEventSubscriber[T IEvent] struct {
	mock.Mock
}

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

Jump to

Keyboard shortcuts

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