modernice / goes

goes is an event-sourcing framework for Go.
https://goes.modernice.dev
Apache License 2.0
134 stars 12 forks source link

Concurrent command handling #41

Closed bounoable closed 1 year ago

bounoable commented 2 years ago

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))
}
bounoable commented 1 year ago

Not needed until now..