Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a Timer object that will wake up the Scheduler at specific times #155

Closed
wants to merge 1 commit into from

Conversation

bensheldon
Copy link
Owner

The intention is to allow a Scheduler to store the times of future scheduled tasks and trigger a wake at those times.

My goal is to allow polling to be significantly dialed back (~1 minute), if not done away with entirely and allow the :async execution mode to be non-noisily set as the default in the Rails development environment. (#139 and #90)

Current concerns:

  • What is the appropriate number of future times to store? I'm a little worried that an unbounded queue is unsafe in production (uses a lot of memory and overlaps with the database's responsibility). But I do think it would make sense in the development environment and match Rails's own AsyncAdapter.
  • Complexity and yet another Concurent::ThreadPoolExecutor. The Timer object has its own threadpool to execute Concurrent::ScheduledTasks that then wake up the GoodJob::Scheduler to fetch and perform the actual job. The GoodJob::Timer is currently entangled with both the Scheduler and the Performer because the Timer needs to refresh its queue of future tasks. I'm struggling with whether the Timer is an implementation detail of the Scheduler, or whether it can be non-complexly extracted like the Poller in Extract Scheduler polling behavior to its own object #152.

@bensheldon
Copy link
Owner Author

Thinking about this more, this can live entirely within the Scheduler which will enqueue either a Concurrent::Future for immediate execution, or a Concurrent::ScheduledTask for scheduled execution. I'll keep the queue idea that the Scheduler manage a bounded number of ScheduledTasks, though in async mode, by default, I might make it unbounded/infinite to match Rails async adapter.

@bensheldon
Copy link
Owner Author

Replaced by #163 to use a Concurrent::ScheduledTask directly.

@bensheldon bensheldon deleted the create_timer branch October 25, 2020 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant