Sha256: cb8e949ae4dc1dec0ca841e219c307f80e9bd95c52868e061a748e74869792a0
Contents?: true
Size: 922 Bytes
Versions: 1
Compression:
Stored size: 922 Bytes
Contents
# frozen_string_literal: true require "securerandom" module Kiev module Sidekiq class RequestId REQUEST_ID = "request_id" REQUEST_DEPTH = "request_depth" TREE_PATH = "tree_path" def call(_worker, job, _queue) Kiev::RequestStore.store[:request_id] = request_id(job) Kiev::RequestStore.store[:request_depth] = request_depth(job) Kiev::RequestStore.store[:tree_path] = tree_path(job) yield end private def request_id(job) # cron jobs will be triggered without request_id job[REQUEST_ID] || SecureRandom.uuid end def tree_root?(job) !job[REQUEST_ID] end def request_depth(job) tree_root?(job) ? 0 : (job[REQUEST_DEPTH].to_i + 1) end def tree_path(job) tree_root?(job) ? SubrequestHelper.root_path(synchronous: false) : job[TREE_PATH] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kiev-2.7.3 | lib/kiev/sidekiq/request_id.rb |