Module: Postburner::Commands
- Extended by:
- ActiveSupport::Concern
- Included in:
- Job
- Defined in:
- app/concerns/postburner/commands.rb
Overview
Concern providing Beanstalkd command methods for Postburner jobs.
Provides methods for interacting with Beanstalkd queue operations such as deleting, kicking, and extending TTR. All methods handle connection retries and gracefully handle missing bkid (e.g., in test mode).
Instance Method Summary collapse
-
#delete! ⇒ void
Deletes the job from the Beanstalkd queue.
-
#extend! ⇒ void
Extends the job’s time-to-run (TTR) in Beanstalkd.
-
#kick! ⇒ void
Kicks a buried job back into the ready queue in Beanstalkd.
-
#remove! ⇒ void
Soft-deletes the job by removing from Beanstalkd and setting removed_at timestamp.
Instance Method Details
#delete! ⇒ void
Does nothing if job has no bkid (e.g., in test mode)
Does not modify ActiveRecord model - only affects Beanstalkd
This method returns an undefined value.
Deletes the job from the Beanstalkd queue.
This is a Beanstalkd operation that removes the job from the queue but does NOT destroy the ActiveRecord model. Use #destroy or #remove! to also update the database record.
Automatically retries with fresh connection if Beanstalkd connection is stale. Called automatically by before_destroy callback when using #destroy.
107 108 109 110 111 112 113 114 |
# File 'app/concerns/postburner/commands.rb', line 107 def delete! return unless self.bk begin self.bk.delete rescue Beaneater::NotConnected => e self.bk!.delete end end |
#extend! ⇒ void
Does nothing if job has no bkid (e.g., in test mode)
This method returns an undefined value.
Extends the job’s time-to-run (TTR) in Beanstalkd.
Calls touch on the Beanstalkd job, extending the TTR by the original TTR value. Use this during long-running operations to prevent the job from timing out.
74 75 76 77 78 79 80 81 |
# File 'app/concerns/postburner/commands.rb', line 74 def extend! return unless self.bk begin self.bk.touch rescue Beaneater::NotConnected => e self.bk!.touch end end |
#kick! ⇒ void
Does nothing if job has no bkid (e.g., in test mode)
Only works on buried jobs - see Beanstalkd documentation
This method returns an undefined value.
Kicks a buried job back into the ready queue in Beanstalkd.
This is a Beanstalkd operation used to retry jobs that were buried due to repeated failures or explicit burial. Does not modify the ActiveRecord model.
Automatically retries with fresh connection if Beanstalkd connection is stale.
44 45 46 47 48 49 50 51 |
# File 'app/concerns/postburner/commands.rb', line 44 def kick! return unless self.bk begin self.bk.kick rescue Beaneater::NotConnected => e self.bk!.kick end end |
#remove! ⇒ void
Idempotent - does nothing if already removed
Does not destroy ActiveRecord model - only soft deletes
This method returns an undefined value.
Soft-deletes the job by removing from Beanstalkd and setting removed_at timestamp.
Unlike #destroy, this preserves the job record in the database for audit trails while removing it from the Beanstalkd queue and marking it as removed.
136 137 138 139 140 |
# File 'app/concerns/postburner/commands.rb', line 136 def remove! return if self.removed_at self.delete! self.update_column(:removed_at, Time.current) end |