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

Tuning retry based on ActiveJob Exceptions implementation #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

tzzzoz
Copy link

@tzzzoz tzzzoz commented Feb 16, 2020

ActiveJob has a built-in retry mechanism.
https://github.com/rails/rails/blob/6-0-stable/activejob/lib/active_job/exceptions.rb#L50-L67

By deserializing the job message properly, we can get the retry working easily with Quiq.

@tzzzoz tzzzoz requested a review from sailor February 16, 2020 16:44
lib/quiq/scheduler.rb Outdated Show resolved Hide resolved
testapp/app/jobs/test_job.rb Outdated Show resolved Hide resolved
@@ -1,9 +1,16 @@
# frozen_string_literal: true

class TestJob < ApplicationJob
class CustomError < StandardError; end

retry_on(CustomError, wait: 5, attempts: 3, queue: :retry) do
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what will the redis key look like for the retry queue?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be prefixed with queue:, queue:retry in this case

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

klass = Object.const_get(payload['job_class'])
args = payload['arguments']
job = klass.deserialize(payload)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: is it a rails/activejob primitive? If so it means that the system won't be usable outside of the rails ecosystem.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should use if defined? ActiveJob here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the retry mechanism is a rails/activejob primitive, but the serialize(which is used in Quiq::Client#push) and deserialize are probably not.

if defined? ActiveJob could be done during the server booting, wdyt?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it could probably do the job!

lib/quiq/scheduler.rb Outdated Show resolved Hide resolved
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.

None yet

2 participants