chore: add context and error handling

This commit is contained in:
2022-12-17 14:36:42 +01:00
parent 80d3c44cb0
commit 98a679d2d3
4 changed files with 23 additions and 16 deletions
+5 -4
View File
@@ -1,6 +1,8 @@
package graph
import (
"context"
"github.com/apex/log"
"gitlab.com/unboundsoftware/eventsourced/eventsourced"
@@ -14,8 +16,7 @@ import (
// It serves as dependency injection for your app, add any dependencies you require here.
type Publisher interface {
Publish(event eventsourced.Event) error
Stop() error
Publish(ctx context.Context, event eventsourced.Event) error
}
type Resolver struct {
@@ -25,6 +26,6 @@ type Resolver struct {
Cache *cache.Cache
}
func (r *Resolver) handler(aggregate eventsourced.Aggregate) (eventsourced.CommandHandler, error) {
return eventsourced.NewHandler(aggregate, r.EventStore, eventsourced.WithEventPublisher(r.Publisher))
func (r *Resolver) handler(ctx context.Context, aggregate eventsourced.Aggregate) (eventsourced.CommandHandler, error) {
return eventsourced.NewHandler(ctx, aggregate, r.EventStore, eventsourced.WithEventPublisher(r.Publisher))
}