redis - Rails ActiveJob - how to stop job from being enqueued in before_enqueue -
i running rails 4.2.8 , want make job run under conditions. doing check in code calling job cleaner contain logic in job class. has done that?
class myjob < applicationjob before_enqueue |job| # check , stop job being enqueued under conditions end def perform(args*) # code here end end
i using sidekiq 4.2.10 background job adapter.
raise exception before_enqueue
. info dhh himself: https://groups.google.com/forum/#!topic/rubyonrails-core/mhd4t90g0g4
this intent. never liked how returning false in filter stops execution. there many side effects,
@stuff = model.something_returning_false
, accidentally halts callback chain. in aj, we're instead going explicit approach requires raise exception, if want stop execution. we'll changing callbacks elsewhere move away "false means halt" in rails 5.0.before_* indeed intended same writing code before execution, in such way can abstracted , mixed in. can write before_* callbacks in super classes without having child need call super, or in modules mix in.
Comments
Post a Comment