Module: ActiveSaga

Defined in:
lib/active_saga.rb,
lib/active_saga/task.rb,
lib/active_saga/errors.rb,
lib/active_saga/backoff.rb,
lib/active_saga/context.rb,
lib/active_saga/railtie.rb,
lib/active_saga/version.rb,
lib/active_saga/workflow.rb,
lib/active_saga/dsl/steps.rb,
lib/active_saga/execution.rb,
lib/active_saga/dsl/options.rb,
lib/active_saga/dsl/signals.rb,
lib/active_saga/stores/base.rb,
lib/active_saga/configuration.rb,
lib/active_saga/jobs/runner_job.rb,
lib/active_saga/serializers/json.rb,
lib/active_saga/stores/active_record.rb,
lib/generators/active_saga/install/install_generator.rb,
lib/generators/active_saga/workflow/workflow_generator.rb

Defined Under Namespace

Modules: Backoff, DSL, Errors, Generators, Jobs, Serializers, Stores Classes: Configuration, Context, Execution, Railtie, Task, Workflow

Constant Summary collapse

VERSION =
"0.1.2"

Class Method Summary collapse

Class Method Details

.cancel!(execution_id, reason: nil) ⇒ Object



87
88
89
# File 'lib/active_saga.rb', line 87

def cancel!(execution_id, reason: nil)
  store.cancel_execution!(execution_id, reason: reason)
end

.complete_step!(execution_id, step_name, payload: nil, idempotency_key: nil) ⇒ Object

Entry point for async completions. Delegates to store and runner.



57
58
59
60
61
# File 'lib/active_saga.rb', line 57

def complete_step!(execution_id, step_name, payload: nil, idempotency_key: nil)
  with_instrumentation("complete", execution_id, step_name) do
    store.complete_step!(execution_id, step_name.to_s, payload: payload, idempotency_key: idempotency_key)
  end
end

.configurationActiveSaga::Configuration



33
34
35
# File 'lib/active_saga.rb', line 33

def configuration
  @configuration ||= Configuration.new
end

.configure {|config| ... } ⇒ Object

Yields global configuration block and memoizes the configuration instance.

Yield Parameters:



40
41
42
# File 'lib/active_saga.rb', line 40

def configure
  yield(configuration)
end

.extend_timeout!(execution_id, step_name, by:) ⇒ Object



73
74
75
# File 'lib/active_saga.rb', line 73

def extend_timeout!(execution_id, step_name, by:)
  store.extend_timeout!(execution_id, step_name.to_s, by: by)
end

.fail_step!(execution_id, step_name, error_class:, message:, details: {}, idempotency_key: nil) ⇒ Object



63
64
65
66
67
68
69
70
71
# File 'lib/active_saga.rb', line 63

def fail_step!(execution_id, step_name, error_class:, message:, details: {}, idempotency_key: nil)
  with_instrumentation("fail", execution_id, step_name) do
    store.fail_step!(execution_id, step_name.to_s,
      error_class: error_class,
      message: message,
      details: details,
      idempotency_key: idempotency_key)
  end
end

.heartbeat!(execution_id, step_name, at: configuration.clock.call) ⇒ Object



77
78
79
# File 'lib/active_saga.rb', line 77

def heartbeat!(execution_id, step_name, at: configuration.clock.call)
  store.heartbeat!(execution_id, step_name.to_s, at: at)
end

.reset_configuration!Object

Resets configuration (mainly for tests)



45
46
47
# File 'lib/active_saga.rb', line 45

def reset_configuration!
  @configuration = Configuration.new
end

.signal!(execution_id, name, payload: nil) ⇒ Object



81
82
83
84
85
# File 'lib/active_saga.rb', line 81

def signal!(execution_id, name, payload: nil)
  with_instrumentation("signal", execution_id, name) do
    store.signal!(execution_id, name.to_s, payload: payload)
  end
end

.storeActiveSaga::Stores::Base

Delegates the store accessor for convenience.



52
53
54
# File 'lib/active_saga.rb', line 52

def store
  configuration.store!
end