enragedginger/akka-quartz-scheduler

Typed scheduler: Why do we need to pass in a typed system to construct a scheduler

khanetor opened this issue · 2 comments

To construct a typed scheduler, we do this

val typedSystem = ActorSystem(MyActor.create(), "my-actor")
val scheduler = QuartzSchedulerTypedExtension(typedSystem)

Then, when we make schedules, we pass in the actor refs with the same message type again

scheduler.schedulerTyped("my-schedule", myActorRef, someMessage)

myActorRef does not have to be the same actor system, as long as it uses the same message. I feel like the typedSystem argument is redundant, because at most it is only used to infer the message type. In that case, passing in a type is good enough.

// Proposal
val scheduler = QuartzSchedulerTypedExtension[Message]()

This is causing me problem in Play, because when I use dependency injection to acquire an actorRef, using bindTypedActor, I only get an actorRef, and not a typed ActorSystem.

Hi @nlhkh feel free to open a PR with a proposed fix and I'll take a look at it

I used the scheduler inside a typed actor, and as such, I can provide the scheduler with context.system.