Class: ActiveJob::Temporal::Cancel::BatchSummary

Inherits:
Object
  • Object
show all
Defined in:
lib/activejob/temporal/cancel/batch_summary.rb

Constant Summary collapse

MAX_REPORTED_ERRORS =
100

Instance Method Summary collapse

Constructor Details

#initializeBatchSummary

Returns a new instance of BatchSummary.



9
10
11
12
# File 'lib/activejob/temporal/cancel/batch_summary.rb', line 9

def initialize
  @mutex = Mutex.new
  @value = { terminated: 0, failed: 0, errors: [] }
end

Instance Method Details

#record_failure(workflow_id, run_id, error) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/activejob/temporal/cancel/batch_summary.rb', line 18

def record_failure(workflow_id, run_id, error)
  mutex.synchronize do
    value[:failed] += 1
    if value[:errors].length < MAX_REPORTED_ERRORS
      value[:errors] << cancellation_error(workflow_id, run_id, error)
    end
  end
end

#record_terminatedObject



14
15
16
# File 'lib/activejob/temporal/cancel/batch_summary.rb', line 14

def record_terminated
  mutex.synchronize { value[:terminated] += 1 }
end

#to_hObject



27
28
29
# File 'lib/activejob/temporal/cancel/batch_summary.rb', line 27

def to_h
  value
end