Class: Yabeda::Shoryuken::ServerMiddleware
- Inherits:
-
Object
- Object
- Yabeda::Shoryuken::ServerMiddleware
- Defined in:
- lib/yabeda/shoryuken/server_middleware.rb
Overview
Shoryuken worker middleware
Instance Method Summary collapse
-
#call(worker, queue, sqs_msg, body) ⇒ Object
rubocop: disable Metrics/AbcSize, Style/ExplicitBlockArgument.
Instance Method Details
#call(worker, queue, sqs_msg, body) ⇒ Object
rubocop: disable Metrics/AbcSize, Style/ExplicitBlockArgument
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/yabeda/shoryuken/server_middleware.rb', line 8 def call(worker, queue, sqs_msg, body) jid = SecureRandom.uuid = Yabeda::Shoryuken.(worker, sqs_msg).to_h labels = Yabeda::Shoryuken.labelize(worker.class, sqs_msg, queue, body).merge() start = Process.clock_gettime(Process::CLOCK_MONOTONIC) begin Yabeda::Shoryuken.jobs_started_at[labels][jid] = start Yabeda.(**) do yield end Yabeda.shoryuken_jobs_success_total.increment(labels) rescue Exception # rubocop: disable Lint/RescueException Yabeda.shoryuken_jobs_failed_total.increment(labels) raise ensure Yabeda.shoryuken_job_runtime.measure(labels, elapsed(start)) Yabeda.shoryuken_jobs_executed_total.increment(labels) Yabeda::Shoryuken.jobs_started_at[labels].delete(jid) end end |