-
-
Notifications
You must be signed in to change notification settings - Fork 204
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
Use async_server
as default execution mode in Development environment
#139
Comments
I believe this is by design. For your expected behavior you should use :async mode as stated in the readme https://github.com/bensheldon/good_job#adapter-options Since it works in the same way as ActiveJob inline mode, is there a need for it in this gem @bensheldon ? |
Yeah, async is probably the correct option for my expectation. Perhaps this ticket is more about what the default should be in dev mode? |
What do other systems with ActiveJob adapters do? Like sidekiq or resque? I think what is appropriate is whatever they do. Is the "default in dev mode" really even up to us, or up to ActiveJob? It may be different in different versions of Rails, I seem to recall at one point Rails changed from :inline as default in dev mode to :async as default in dev mode. |
Thanks everyone for the discussion! I'm not quite confident of a strong path forward, but let me share my thinking today:
|
I'm also running into some confusion with what I believe to be a related issue. It seems as part of this @bensheldon Is this expected? And if not, let me know if you'd like me to create a new issue here. |
@oyeanuj yes, that is expected behavior. From readme:
Arguably the emphasis should be on immediately in that sentence. Practically speaking, I'd love your feedback about the experience of running the # config/environments/development.rb
config.active_job.queue_adapter = GoodJob::Adapter.new(execution_mode: :async) |
Update on this. I expect the next release ( This is the configuration I'm expecting to default to, that works in the current release ( # config/environment/development.rb
config.active_job.queue_adapter = :good_job
if ENV['GOOD_JOB_EXECUTION_MODE']
config.good_job.execution_mode = ENV['GOOD_JOB_EXECUTION_MODE'].to_sym
elsif Rails.const_defined?("Server")
config.good_job.execution_mode = :async
elsif Rails.const_defined?("Console")
config.good_job.execution_mode = :external
end
config.good_job.poll_interval = 60 # seconds |
Just wanted to update this issue that |
For #307:
|
async_server
as default execution mode in Development environment
Hi @bensheldon
In development mode, good_job runs :inline, but seems to ignore the
scheduled_at
attribute and executes the job immediately. This makes sense, but was somewhat unexpected and I had to refer to the docs to figure it out.I expected it to run more akin to an async, in-process job, but still respect the
scheduled_at
.What happened
I had called
MyJob.set(wait: 5.seconds).perform_later
and the job executed immediately.This created a job record in a seemingly impossible (or at least undesirable) state:
This job has
performed_at
set earlier thanscheduled_at
.What I expected
That the job would enqueue, wait 5 seconds, and execute async, but in-process, much like the default Rails async job behaviour.
This matches what will happen in production more closely and avoids records in impossible states.
Thoughts?
The text was updated successfully, but these errors were encountered: