Documentation ¶
Index ¶
- func LogErrors(ctx context.Context, errs ...<-chan error)
- type Setup
- func (s *Setup) Aggregates(estore event.Store) *repository.Repository
- func (s *Setup) Commands(ereg *codec.Registry, ebus event.Bus) (command.Bus, *codec.Registry)
- func (s *Setup) Context() (context.Context, context.CancelFunc)
- func (s *Setup) EventBus(ctx context.Context, enc codec.Encoding, serviceName string) (_ event.Bus, disconnect func())
- func (s *Setup) Events(ctx context.Context, serviceName string) (_ event.Bus, _ event.Store, _ *codec.Registry, disconnect func())
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Setup ¶
type Setup struct{}
Setup is a type that provides methods to set up the necessary components for running the "todo" application. It includes methods to obtain a context with cancellation, set up event buses and stores, register commands, and create a repository for aggregates.
func (*Setup) Aggregates ¶
func (s *Setup) Aggregates(estore event.Store) *repository.Repository
Aggregates returns a *repository.Repository for managing aggregates using the given event.Store.
func (*Setup) Commands ¶
Commands returns a command.Bus and a *codec.Registry for registering and handling commands for the todo application. It takes a *codec.Registry and an event.Bus as arguments, used to register events for commands.
func (*Setup) Context ¶
func (s *Setup) Context() (context.Context, context.CancelFunc)
Context returns a context.Context that is cancelled when the program receives an interrupt signal (os.Interrupt, os.Kill, syscall.SIGTERM).
func (*Setup) EventBus ¶
func (s *Setup) EventBus(ctx context.Context, enc codec.Encoding, serviceName string) (_ event.Bus, disconnect func())
EventBus returns a new NATS event.Bus(https://pkg.go.dev/github.com/modernice/goes/event#Bus) that uses the given codec.Encoding. The returned function can be used to disconnect from the NATS server.
func (*Setup) Events ¶
func (s *Setup) Events(ctx context.Context, serviceName string) (_ event.Bus, _ event.Store, _ *codec.Registry, disconnect func())
Events returns an event bus, an event store, a codec registry and a disconnect function. The event bus is an instance of event.Bus(https://pkg.go.dev/github.com/modernice/goes/event#Bus) that can be used to publish events. The event store is an instance of event.Store(https://pkg.go.dev/github.com/modernice/goes/event/eventstore#Store) that can be used to store and retrieve events. The codec registry is an instance of codec.Registry(https://pkg.go.dev/github.com/modernice/goes/codec#Registry) that can be used to marshal and unmarshal events. The disconnect function should be called when the application shuts down to disconnect from the event bus.