-
Notifications
You must be signed in to change notification settings - Fork 843
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
Configures ActiveJob with solid_queue gem #1415
base: master
Are you sure you want to change the base?
Configures ActiveJob with solid_queue gem #1415
Conversation
@@ -263,6 +263,9 @@ | |||
resources :reparents, only: [:new, :create] | |||
end | |||
|
|||
# only admin should be able to access it.. right ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's allow any moderator to use it. It'd be good to give them insight into the kinds of partial outages that people might ask about when jobs fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now, I have configured basic_http_authentication
with credentials stored in Rails credentials. Integrating with our native authentication workflow may require some more work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a tutorial for basic auth. The interesting thing was setting config.mission_control.jobs.base_controller_class
- if you set that to our Mod::ModeratorController
(from app/controllers/mod/moderator_controller.rb
, be careful, there are several controllers with very similar names) would it use our authentication?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be very convenient for the moderators. But, it will require more
work. For example, ModController inherits from ApplicationController which
has n+1 query check middleware, that will cause problem with
mission-control gem.
My guess is if we make a new JobModcontroller class inheriting from
Actioncontroller::Base, maybe we can make it work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this is working.
rahul1990gupta#2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another option is to extract the authentication module into a concern and use it for ApplicationController
and JobsModController
rahul1990gupta#3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A Concern sounds like the exact right tool for the job, please extract one to share authentication between the mission control and mod controllers. Thanks for figuring out our options here.
I know you haven't requested a review yet, but I am excited to see you starting this. I appreciate you taking on all these features related to Rails 8! The Rails implementation of |
@@ -1,7 +1,7 @@ | |||
# typed: false | |||
|
|||
module TimeAgoInWords | |||
def time_ago_in_words(time) | |||
def how_long_ago(time) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably already on your to-do list, but: there are a lot more calls to time_ago_in_words
in the views to update, and please rename time_ago_in_words_label
to how_long_ago_label
to match so it's clear what that helper is doing.
@@ -0,0 +1,7 @@ | |||
class ExpireOldRibbonsJob < ApplicationJob | |||
queue_as :default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably use queues based on SLOs, https://alexis.bernard.io/blog/2023-10-15-background-job-queues-and-priorities-may-be-the-wrong-path.html is a half decent summary of doing so (and links off to Ben Sheldon of GoodJob maintainer, and Nate Berkopec of Speedshop … notoriety?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen this in production at scale and agree.
What do you think about using rails's
I know it looks more verbose than our implementation of "how_long_ago", but it can be customized using engligh locale file. here is an example from official reference
Another reason for using rails's method is their support of localization. and that is important for us because lobsters codebase is used to power a live french hacking website and many more. And staying close to rails's feature will take it other mods to launch their local version.
|
This PR is starting to extend its initial scope. So, I have taken out the two unrelated components
|
Overview
This PR closely follows the recommendation for setting up active job from the rails official video: https://www.youtube.com/watch?v=ReyKfb12EVU
This PR
TimeAgoInWords
from ApplicationHelper because it is already provided by rails and it was having conflict with mission_controls method calling rails'stime_ago_in_words
which has different signature than the one defined here. https://github.com/rails/mission_control-jobs/blob/ca09138a06d0322a4a39a63ebf253ba0eb56bd7c/app/helpers/mission_control/jobs/dates_helper.rb#L17Testing
Deployment playbook
rails db:prepare
will generate the required database and corresponding tables.Next Steps.
This will lay the foundation for #1299 and other async jobs.