modernice/goes

Concurrent command handling

Closed this issue · 1 comments

Add options to enable concurrent command handling.

Standalone command handler

package example

func example(bus command.Bus) {
  h := command.NewHandler(bus)

  h.Handle(context.TODO(), "foo", func(ctx command.Context) error { ... }, command.Workers(4))
}

Aggregate-based command handler

package example

type Foo struct {
  *aggregate.Base
  *handler.BaseHandler
}

func NewFoo(id uuid.UUID) *Foo { ... }

func example(bus command.Bus, repo aggregate.Repository) {
  h := handler.New(NewFoo, repo, bus)

  h.Handle(context.TODO(), command.Workers(4))
}

Not needed until now..