Module: Smith::Workflow::SplitStepPersistence::Checkpoint
- Included in:
- Smith::Workflow::SplitStepPersistence
- Defined in:
- lib/smith/workflow/split_step_persistence/checkpoint.rb
Instance Method Summary collapse
- #complete_persisted_step! ⇒ Object
- #persist!(key = nil, adapter: Smith.persistence_adapter) ⇒ Object
Instance Method Details
#complete_persisted_step! ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/smith/workflow/split_step_persistence/checkpoint.rb', line 7 def complete_persisted_step! completion_claimed = false previous_phase = claim_split_step_completion! completion_claimed = true completed = false payload = @split_step_adapter.fetch(@split_step_persistence_key) unless persisted_split_step_checkpoint?(payload) recover_rolled_back_split_step_checkpoint!(payload) raise WorkflowError, "the persisted split-step checkpoint is not committed" end @split_step_mutex.synchronize do @persistence_version = @split_step_checkpoint_version clear_step_in_progress! clear_split_step_boundary! end completed = true self ensure restore_incomplete_checkpoint!(previous_phase) if completion_claimed && !completed end |
#persist!(key = nil, adapter: Smith.persistence_adapter) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/smith/workflow/split_step_persistence/checkpoint.rb', line 29 def persist!(key = nil, adapter: Smith.persistence_adapter) checkpoint_claimed = false resolved_key, store = resolve_split_step_target(key, adapter) checkpoint_claimed = claim_split_step_checkpoint! result = super(resolved_key, adapter: store) do |payload, next_version| capture_split_step_payload!(payload, next_version, checkpoint_claimed:) end @split_step_mutex.synchronize { @split_step_phase = :checkpointed } if checkpoint_claimed result rescue StandardError mark_split_step_checkpoint_unknown! if checkpoint_claimed raise end |