-
Notifications
You must be signed in to change notification settings - Fork 46
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
Infer interruption adapter from queue adapter, take 2 #450
Conversation
f0fbea8
to
ffe6d9b
Compare
@bdewater Sorry it's taken us so long to get this change out. I hope this gives us a good way to move forward. I can't seem to tag you as reviewer, but I'd welcome your input. |
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.
Left a few small comments but it's looking good! Thanks @Mangara and @sambostock. Also cc'ing @plasticine for the original PR I based my work on.
51a7958
to
a37aabd
Compare
require_relative "./job-iteration/iteration" | ||
require_relative "./job-iteration/log_subscriber" | ||
require_relative "./job-iteration/railtie" | ||
|
||
module JobIteration | ||
IntegrationLoadError = Class.new(StandardError) |
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.
Is this considered part of the public API? Seems unlikely someone would be referencing the constant though.
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.
The only references I can find in GitHub are RBI files: https://github.com/search?q=JobIteration%3A%3AIntegrationLoadError&type=code
I highly doubt anyone was rescuing this.
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.
Sounds good. Good reminder for us to ensure we're masking things as # @api private
though, as we are with the built in adapters constant.
71f045d
to
9c13ff9
Compare
lib/job-iteration/iteration.rb
Outdated
def interruption_adapter | ||
JobIteration.interruption_adapter || JobIteration::InterruptionAdapters.lookup(queue_adapter_name) | ||
end |
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.
Having this method as a class method allowed the job class to overwrite it, which feels like it would be useful in tests, if nothing else (since we plan to get rid of the global JobIteration.interruption_adapter
).
By moving the logic into the private method marked as @private
, we've made it so it can't be controlled without violating the privacy contract.
Is that something we should reconsider?
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.
Discussed offline, but I feel like for tests we can register a configurable TestAdapter for when the test queue adapter is used. For other cases, I agree there's a missing configuration option, but I'm not convinced the interruption adapter is the right place for that. I like keeping its scope small - to tell us when the job worker is stopping.
9c13ff9
to
d8cecc7
Compare
lib/job-iteration.rb
Outdated
Deprecation.warn("Setting JobIteration.interruption_adapter is deprecated."\ | ||
" Use JobIteration::InterruptionAdapters.register(:foo, callable) instead"\ | ||
" to register the callable (a proc, method, or other object responding to #call)"\ | ||
" as the interruption adapter for queue adapter :foo.") |
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 could have sworn there was a cop that forced trailing spaces and spaces before the \
...
Deprecation.warn("Setting JobIteration.interruption_adapter is deprecated."\ | |
" Use JobIteration::InterruptionAdapters.register(:foo, callable) instead"\ | |
" to register the callable (a proc, method, or other object responding to #call)"\ | |
" as the interruption adapter for queue adapter :foo.") | |
Deprecation.warn("Setting JobIteration.interruption_adapter is deprecated. " \ | |
"Use JobIteration::InterruptionAdapters.register(:foo, callable) instead " \ | |
"to register the callable (a proc, method, or other object responding to #call) " \ | |
"as the interruption adapter for queue adapter :foo.") |
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.
There is, LineContinuationLeadingSpace
, and it should be enabled.
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.
Not sure why it wasn't flagging this, but I fixed the spaces.
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.
Ahh, while we do have it enabled on rubocop-shopify@main
, it's still disabled in the latest release (v2.14.0
), which is what this repo is using.
d8cecc7
to
0322775
Compare
0322775
to
db81365
Compare
This PR is an attempt to redo #367 in a backwards compatible way. That will allow us to release this as 1.x, and remove the deprecations in 2.0.
Future behaviour
Like that PR, the desired interface going forward is:
queue_adapter_name
of the job class.Backwards compatibility
The major differences are that:
JobIteration.interruption_adapter
is set, we use that instead:JobIteration.interruption_adapter=
, we print a deprecation warning:JobIteration.interruption_adapter
is not set), we log a deprecation warning: