Skip to content

Tuning retry based on ActiveJob Exceptions implementation#4

Open
tzzzoz wants to merge 5 commits intosailor:masterfrom
tzzzoz:master
Open

Tuning retry based on ActiveJob Exceptions implementation#4
tzzzoz wants to merge 5 commits intosailor:masterfrom
tzzzoz:master

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
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.

# Then load the definition of the job + deserialize it to a job object
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!

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.

2 participants