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

Customize the parent class of SolidQueue::RecurringJob #356

Open
tmimura39 opened this issue Sep 20, 2024 · 0 comments
Open

Customize the parent class of SolidQueue::RecurringJob #356

tmimura39 opened this issue Sep 20, 2024 · 0 comments

Comments

@tmimura39
Copy link
Contributor

tmimura39 commented Sep 20, 2024

Introduction

Allow specifying recurring tasks just with a "command"

I find this feature very interesting.

However, there is one barrier to its use.
That is, the parent of SolidQueue::RecurringJob is fixed at ActiveJob::Base.

I have defined error handling in ApplicationJob as described below.
https://github.com/rails/solid_queue/blob/67b964d5e9d1120e0f198dc1ef538a0aff966133/README.md#error-reporting-on-jobs

This error handling does not work when using “command”.

Proposal

How about allowing customization of the SolidQueue::RecurringJob parent class?

Thinking something similar to MaintenanceTasks.parent_controller.
https://github.com/Shopify/maintenance_tasks/blob/d98544fb3de714a14082b64e6831980945db01cf/README.md#customizing-the-parent-controller-for-the-web-ui

What do you think?

Workaround

Just extend SolidQueue::RecurringJob.

module JobErrorHandling
  extend ActiveSupport::Concern

  included do
    rescue_from(Exception) do |exception|
      Rails.error.report(exception)
      raise exception
    end
  end
end

class ApplicationJob < ActiveJob::Base
  include JobErrorHandling
end

Rails.application.config.after_initialize do
  SolidQueue::RecurringJob.include(JobErrorHandling)
end
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

No branches or pull requests

1 participant