README.md in sidekiq-hierarchy-1.1.0 vs README.md in sidekiq-hierarchy-2.0.0

- old
+ new

@@ -105,15 +105,21 @@ > [workflow.enqueued_at, workflow.run_at, workflow.complete_at] => [2015-11-11 15:00:42 -0800, 2015-11-11 15:00:42 -0800, 2015-11-11 15:01:32 -0800] ``` ```ruby +> workflow.job_count # stored value, no iteration necessary +=> 33 + > workflow.jobs.count # lazily eval'd => 33 > workflow.jobs.map(&:jid) => ["11c3ec3df251ebb646f910d7", "f003db430a0eae99d72f1b7a", "bc2cf8f3de3b87f9a4c3c10e", ...] + +> workflow.finished_job_count +=> 33 ``` ```ruby > root_job = workflow.root => <Sidekiq::Hierarchy::Job...> @@ -174,11 +180,11 @@ - current `#status` (`:enqueued`, `:running`, `:complete`, `:requeued`, `:failed`) - timestamps for all status changes (`#enqueued_at`, `#run_at`, etc.) - tree exploration (`#root`, `#parent`, `#children`, `#leaf?`, etc.) - lazy enumerators over jobs and workflows (`Workflow#jobs`, `WorkflowSet#each`) -- current workflow and job id context (`Sidekiq::Hierarchy.current_workflow`, `.current_jid`) +- current workflow and job context (`Sidekiq::Hierarchy.current_workflow`, `.current_job`) Each `Workflow` can be treated as a Redis-backed hash (all values will be coerced to strings). Combined with the fact that the current workflow context can always be accessed via `Sidekiq::Hierarchy.current_workflow` (nil if not in a workflow), you can pass arbitrary information through a work tree. --- @@ -274,11 +280,11 @@ end ``` In the background, Sidekiq-hierarchy inserts and decodes two headers: -- Sidekiq-Jid: the job id of the parent worker, if any +- Sidekiq-Job: the job id of the parent worker, if any - Sidekiq-Workflow: the workflow JID, if tracking is enabled (`workflow: true` in sidekiq_options) Even if you are not using Faraday, adding these headers should be easy with your network library of choice. ## Advanced Options @@ -338,17 +344,17 @@ On the server side, _inside_ the hierarchy middleware to ensure variables are set: ```ruby class FailFast::ServerMiddleware def call(worker, job, queue) - current_jid = Sidekiq::Hierarchy.current_jid + current_job = Sidekiq::Hierarchy.current_job workflow = Sidekiq::Hierarchy.current_workflow return if workflow && workflow[:fail_fast] yield rescue => e - if workflow && Sidekiq::Hierarchy::Job.find(current_jid).failed? + if workflow && current_job.failed? workflow[:fail_fast] = '1' end raise # make sure to propagate exception up end end