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.5"
Class Method Summary
collapse
-
.cancel!(execution_id, reason: nil) ⇒ Object
-
.complete_step!(execution_id, step_name, payload: nil, idempotency_key: nil) ⇒ Object
Entry point for async completions.
-
.configuration ⇒ ActiveSaga::Configuration
-
.configure {|config| ... } ⇒ Object
Yields global configuration block and memoizes the configuration instance.
-
.events_for_execution(execution_id) ⇒ Object
-
.execution(execution_id) ⇒ Object
-
.executions(**options) ⇒ Object
-
.extend_timeout!(execution_id, step_name, by:) ⇒ Object
-
.fail_step!(execution_id, step_name, error_class:, message:, details: {}, idempotency_key: nil) ⇒ Object
-
.failure_summary(execution_id) ⇒ Object
-
.heartbeat!(execution_id, step_name, at: configuration.clock.call) ⇒ Object
-
.reset_configuration! ⇒ Object
Resets configuration (mainly for tests).
-
.signal!(execution_id, name, payload: nil) ⇒ Object
-
.steps_for_execution(execution_id) ⇒ Object
-
.store ⇒ ActiveSaga::Stores::Base
Delegates the store accessor for convenience.
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
|
33
34
35
|
# File 'lib/active_saga.rb', line 33
def configuration
@configuration ||= Configuration.new
end
|
Yields global configuration block and memoizes the configuration instance.
40
41
42
|
# File 'lib/active_saga.rb', line 40
def configure
yield(configuration)
end
|
.events_for_execution(execution_id) ⇒ Object
103
104
105
|
# File 'lib/active_saga.rb', line 103
def events_for_execution(execution_id)
store.events_for(execution_id)
end
|
.execution(execution_id) ⇒ Object
91
92
93
|
# File 'lib/active_saga.rb', line 91
def execution(execution_id)
store.load_execution(execution_id)
end
|
.executions(**options) ⇒ Object
95
96
97
|
# File 'lib/active_saga.rb', line 95
def executions(**options)
store.executions(**options)
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
|
.failure_summary(execution_id) ⇒ Object
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/active_saga.rb', line 107
def failure_summary(execution_id)
execution = store.load_execution(execution_id)
return { execution_id:, state: nil, failures: [] } unless execution
steps = store.steps_for(execution_id)
failures = steps.select { |step| %w[failed timed_out].include?(step[:state]) }
.map do |step|
{
name: step[:name],
state: step[:state],
attempts: step[:attempts],
last_error_class: step[:last_error_class],
last_error_message: step[:last_error_message],
last_error_details: step[:last_error_details],
last_error_at: step[:last_error_at]
}
end
{
execution_id: execution.id,
workflow: execution.workflow_class,
state: execution.state,
failures: failures
}
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
|
.steps_for_execution(execution_id) ⇒ Object
99
100
101
|
# File 'lib/active_saga.rb', line 99
def steps_for_execution(execution_id)
store.steps_for(execution_id)
end
|
Delegates the store accessor for convenience.
52
53
54
|
# File 'lib/active_saga.rb', line 52
def store
configuration.store!
end
|