Module: Jiggler::Support::Helper
- Included in:
- BaseAcknowledger, BaseFetcher, Launcher, Manager, Retrier, Jiggler::Scheduled::Enqueuer, Jiggler::Scheduled::Poller, Jiggler::Scheduled::Requeuer, Jiggler::Stats::Monitor, Worker
- Defined in:
- lib/jiggler/support/helper.rb
Instance Method Summary collapse
- #log_error(ex, **ctx) ⇒ Object
- #log_error_short(err, **ctx) ⇒ Object
- #logger ⇒ Object
- #safe_async(name) ⇒ Object
- #scan_all(mask) ⇒ Object
- #tid ⇒ Object
Instance Method Details
#log_error(ex, **ctx) ⇒ Object
14 15 16 17 18 |
# File 'lib/jiggler/support/helper.rb', line 14 def log_error(ex, **ctx) err_context = ctx.compact.map { |k, v| "#{k}=#{v}" }.join(' ') logger.error("error_message='#{ex.}' #{err_context}") logger.error(ex.backtrace.first(12).join("\n")) unless ex.backtrace.nil? end |
#log_error_short(err, **ctx) ⇒ Object
20 21 22 23 |
# File 'lib/jiggler/support/helper.rb', line 20 def log_error_short(err, **ctx) err_context = ctx.compact.map { |k, v| "#{k}=#{v}" }.join(' ') logger.error("error_message='#{err.}' #{err_context}") end |
#logger ⇒ Object
25 26 27 |
# File 'lib/jiggler/support/helper.rb', line 25 def logger @config.logger end |
#safe_async(name) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/jiggler/support/helper.rb', line 6 def safe_async(name) Async do yield rescue Exception => ex log_error(ex, context: name, tid: tid) end end |
#scan_all(mask) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/jiggler/support/helper.rb', line 29 def scan_all(mask) @config.with_sync_redis do |conn| start = '0' all_keys = [] loop do start, keys = conn.call('SCAN', start, 'MATCH', mask) break if keys.empty? all_keys += keys break if start == '0' end all_keys end end |
#tid ⇒ Object
43 44 45 46 |
# File 'lib/jiggler/support/helper.rb', line 43 def tid return unless Async::Task.current? (Async::Task.current.object_id ^ ::Process.pid).to_s(36) end |