Skip to content

Commit f06c166

Browse files
committed
refactor: add a supervisor strategy to the projection backing actor
1 parent fe1c139 commit f06c166

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

engine.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,14 @@ func (engine *Engine) AddProjection(ctx context.Context, name string, handler pr
234234
actorSystem := engine.actorSystem
235235
engine.mutex.Unlock()
236236

237-
// projections are long-lived goakt
238-
if _, err := actorSystem.Spawn(ctx, name, actor, goakt.WithLongLived()); err != nil {
237+
// projections are long-lived actors
238+
// TODO: resuming the projection may not be a good option. Need to figure out the correlation between the handler
239+
// TODO: retry policy and the backing actor behavior
240+
supervisor := goakt.NewSupervisor(goakt.WithAnyErrorDirective(goakt.ResumeDirective))
241+
if _, err := actorSystem.Spawn(ctx, name,
242+
actor,
243+
goakt.WithLongLived(),
244+
goakt.WithSupervisor(supervisor)); err != nil {
239245
return fmt.Errorf("failed to register the projection=(%s): %w", name, err)
240246
}
241247

0 commit comments

Comments
 (0)