enragedginger / akka-quartz-scheduler

Quartz Extension and utilities for cron-style scheduling in Akka
Other
559 stars 114 forks source link

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

Closed khanetor closed 3 years ago

khanetor commented 3 years ago

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.

enragedginger commented 3 years ago

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

khanetor commented 3 years ago

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