Class: EdiFlowFinalizer
- Inherits:
-
Object
- Object
- EdiFlowFinalizer
- Defined in:
- app/workers/edi_flow_finalizer.rb
Overview
Sidekiq Pro batch callback for a fanned-out EDI flow.
The scheduled dispatcher's own AppSignal check-in proves the cron fired; this
proves the WORK finished, and says how much of it failed. Before the fan-out
there was no such signal at all — execute_flow's per-partner result array,
:error entries and all, was returned to a Sidekiq worker and discarded.
Note what a batch cannot tell you: it completes when every job finishes or
dies, so a job that HANGS never completes and this never fires. Hang detection
is EdiStalledFeedSweep's job, not this one's.
Instance Method Summary collapse
-
#on_complete(status, options) ⇒ void
Reports the outcome of the completed batch.
Instance Method Details
#on_complete(status, options) ⇒ void
This method returns an undefined value.
Reports the outcome of the completed batch.
The denominator is status.total, the batch's own job count, rather than
anything the dispatcher passed: a uniqueness conflict can coalesce a job away
before it joins the batch, and "2 of 11 failed" would then be wrong.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/workers/edi_flow_finalizer.rb', line 25 def on_complete(status, ) flow = .fetch('flow') duration = Time.current - Time.iso8601(.fetch('started_at')) failures = status.failures.to_i total = status.total.to_i if failures.positive? ErrorReporting.error( "EDI #{flow} batch #{status.bid}: #{failures} of #{total} orchestrator job(s) failed", source: :background, flow: flow, batch_id: status.bid ) end report_completion(flow:, status:, total:, failures:, duration:) end |