cmd

package
v0.0.0-...-f1379e3 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogErrors

func LogErrors(ctx context.Context, errs ...<-chan error)

LogErrors logs all errors from the provided channels.

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

func (s *Setup) Commands(ereg *codec.Registry, ebus event.Bus) (command.Bus, *codec.Registry)

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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