Module: Postburner::Tracked
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/postburner/tracked.rb
Overview
Concern for ActiveJob classes to opt-in to PostgreSQL tracking.
Simply include this module in your ActiveJob class to enable full audit trail persistence in PostgreSQL. Without this, jobs execute as “default” jobs (Beanstalkd only, no PostgreSQL overhead).
Instance Method Summary collapse
-
#bk ⇒ Beaneater::Job?
Returns the Beanstalkd job object for direct queue operations.
-
#extend! ⇒ void
Extends the job’s time-to-run (TTR) in Beanstalkd.
-
#log(message, level: :info) ⇒ void
Appends a log message to the job’s audit trail.
-
#log!(message, level: :info) ⇒ void
Appends a log message and immediately persists to database.
-
#log_exception(exception) ⇒ void
Tracks an exception in the job’s errata array.
-
#log_exception!(exception) ⇒ void
Tracks an exception and immediately persists to database.
Instance Method Details
#bk ⇒ Beaneater::Job?
Returns the Beanstalkd job object for direct queue operations.
Provides access to the underlying Beaneater job object through the TrackedJob wrapper. Use this to perform Beanstalkd operations like touch, bury, release, etc.
144 145 146 |
# File 'lib/postburner/tracked.rb', line 144 def bk postburner_job&.bk end |
#extend! ⇒ void
This method returns an undefined value.
Extends the job’s time-to-run (TTR) in Beanstalkd.
Convenience method that 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.
167 168 169 |
# File 'lib/postburner/tracked.rb', line 167 def extend! postburner_job&.extend! end |
#log(message, level: :info) ⇒ void
This method returns an undefined value.
Appends a log message to the job’s audit trail.
Only available for tracked jobs. Logs are stored in the Postburner::Job record’s ‘logs` JSONB array.
58 59 60 |
# File 'lib/postburner/tracked.rb', line 58 def log(, level: :info) postburner_job&.log(, level: level) end |
#log!(message, level: :info) ⇒ void
This method returns an undefined value.
Appends a log message and immediately persists to database.
Use this for important log messages that should be saved immediately rather than batched with other updates.
77 78 79 |
# File 'lib/postburner/tracked.rb', line 77 def log!(, level: :info) postburner_job&.log!(, level: level) end |
#log_exception(exception) ⇒ void
This method returns an undefined value.
Tracks an exception in the job’s errata array.
Appends exception details (class, message, backtrace) to the in-memory errata array. Does NOT persist immediately.
98 99 100 |
# File 'lib/postburner/tracked.rb', line 98 def log_exception(exception) postburner_job&.log_exception(exception) end |
#log_exception!(exception) ⇒ void
This method returns an undefined value.
Tracks an exception and immediately persists to database.
116 117 118 |
# File 'lib/postburner/tracked.rb', line 116 def log_exception!(exception) postburner_job&.log_exception!(exception) end |