protoactor-go icon indicating copy to clipboard operation
protoactor-go copied to clipboard

[Feature] Allow to run StopFuture and PoisonFuture with a custom timeout

Open melaurent opened this issue 5 years ago • 3 comments

The case occurred to me that I needed to shut down all my main actors from the root context. Some of the actors perform state serializations, and synchronization on some remote database. In happens that the stopping of the actor can take more than 10 seconds, which is the default time in StopFuture and PoinsonFuture methods of the root context, thus resulting in a time out. Is there an alternative way I can use to gracefully shut down my actors from the root context ? Or increase this time out ? Adding a duration parameter would create an API break

melaurent avatar Aug 14 '19 16:08 melaurent

Have the actor spawn a go routine let the go routine do the work. Instead of waiting for it to finish ? Would that help ?

otherview avatar Aug 19 '19 09:08 otherview

Thanks I will do that for now. But that forces me to introduce a new synchronization mechanism on top of the actor system, as I have to ensure the goroutine is done before exiting the main process.

melaurent avatar Aug 19 '19 09:08 melaurent

@melaurent You could go into the template and write your own custom logic.. 🤔
This is the logic for the timeout itself, I suppose you could derive stuff from there if you need extra operations 😄

https://github.com/AsynkronIT/protoactor-go/blob/b225d28383f2318e0513dfabd22a3037f9043ffd/protobuf/protoc-gen-gograin/template.go#L131-L144

otherview avatar Aug 21 '20 15:08 otherview