Module: Shikibu
- Defined in:
- lib/shikibu.rb,
lib/shikibu.rb,
lib/shikibu/app.rb,
lib/shikibu/errors.rb,
lib/shikibu/replay.rb,
lib/shikibu/worker.rb,
lib/shikibu/context.rb,
lib/shikibu/locking.rb,
lib/shikibu/version.rb,
lib/shikibu/activity.rb,
lib/shikibu/channels.rb,
lib/shikibu/workflow.rb,
lib/shikibu/constants.rb,
lib/shikibu/retry_policy.rb,
lib/shikibu/outbox/relayer.rb,
lib/shikibu/notify/pg_notify.rb,
lib/shikibu/notify/wake_event.rb,
lib/shikibu/notify/notify_base.rb,
lib/shikibu/storage/migrations.rb,
lib/shikibu/middleware/rack_app.rb,
lib/shikibu/integrations/sidekiq.rb,
lib/shikibu/storage/sequel_storage.rb,
lib/shikibu/integrations/active_job.rb
Overview
Optional integrations (autoload)
Defined Under Namespace
Modules: ChannelMode, Channels, DataType, EventType, Integrations, Locking, Middleware, Notify, Outbox, OutboxStatus, Status, Storage Classes: Activity, App, ChannelModeConflictError, Configuration, Error, EventTimeoutError, LockNotAcquiredError, MessageTimeoutError, RecurSignal, ReplayEngine, RetryExhaustedError, RetryPolicy, TerminalError, WaitForChannelSignal, WaitForTimerSignal, Worker, Workflow, WorkflowCancelledError, WorkflowContext, WorkflowNotFoundError, WorkflowNotRegisteredError
Constant Summary collapse
- VERSION =
'0.2.0'- FRAMEWORK =
Framework identifier for cross-language support
'ruby'
Class Attribute Summary collapse
-
.app ⇒ Object
Global app instance.
Class Method Summary collapse
-
.clear_registry! ⇒ Object
Clear all registered workflows and compensations (mainly for testing).
-
.compensation_registry ⇒ Object
Registry for compensation functions (Romancy/Edda compatible).
-
.configure {|config| ... } ⇒ Object
Configure the global app.
-
.get_compensation(name) ⇒ Proc?
Get a registered compensation function by name.
-
.get_workflow(name) ⇒ Object
Get a registered workflow by name.
-
.register_compensation(name, &block) ⇒ Object
Register a compensation function.
-
.register_workflow(workflow_class) ⇒ Object
Register a workflow class.
-
.result(instance_id) ⇒ Object
Get workflow result.
-
.run(workflow, **input) ⇒ Object
Run a workflow.
-
.send_event(event_type, data, metadata: nil) ⇒ Object
Send event to workflows.
-
.status(instance_id) ⇒ Object
Get workflow status.
-
.workflow_registry ⇒ Object
Registry for workflow definitions.
Class Attribute Details
.app ⇒ Object
Global app instance
12 13 14 |
# File 'lib/shikibu.rb', line 12 def app @app end |
Class Method Details
.clear_registry! ⇒ Object
Clear all registered workflows and compensations (mainly for testing)
56 57 58 59 60 |
# File 'lib/shikibu.rb', line 56 def clear_registry! @workflow_registry = {} @compensation_registry = {} @app = nil end |
.compensation_registry ⇒ Object
Registry for compensation functions (Romancy/Edda compatible)
31 32 33 |
# File 'lib/shikibu.rb', line 31 def compensation_registry @compensation_registry ||= {} end |
.configure {|config| ... } ⇒ Object
Configure the global app
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/shikibu.rb', line 63 def configure config = Configuration.new yield config @app = App.new( database_url: config.database_url, service_name: config.service_name, auto_migrate: config.auto_migrate, hooks: config.hooks, use_listen_notify: config.use_listen_notify ) end |
.get_compensation(name) ⇒ Proc?
Get a registered compensation function by name
49 50 51 52 53 |
# File 'lib/shikibu.rb', line 49 def get_compensation(name) return nil if name.nil? compensation_registry[name.to_s] end |
.get_workflow(name) ⇒ Object
Get a registered workflow by name
26 27 28 |
# File 'lib/shikibu.rb', line 26 def get_workflow(name) workflow_registry[name] end |
.register_compensation(name, &block) ⇒ Object
Register a compensation function
42 43 44 |
# File 'lib/shikibu.rb', line 42 def register_compensation(name, &block) compensation_registry[name.to_s] = block end |
.register_workflow(workflow_class) ⇒ Object
Register a workflow class
20 21 22 23 |
# File 'lib/shikibu.rb', line 20 def register_workflow(workflow_class) name = workflow_class.workflow_name workflow_registry[name] = workflow_class end |
.result(instance_id) ⇒ Object
Get workflow result
97 98 99 100 |
# File 'lib/shikibu.rb', line 97 def result(instance_id) ensure_app! app.get_result(instance_id) end |
.run(workflow, **input) ⇒ Object
Run a workflow
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/shikibu.rb', line 76 def run(workflow, **input) ensure_app! if workflow.is_a?(Class) app.register(workflow) unless workflow_registry.key?(workflow.workflow_name) app.start_workflow(workflow, **input) else # Instance passed - extract class and input workflow_class = workflow.class app.register(workflow_class) unless workflow_registry.key?(workflow_class.workflow_name) app.start_workflow(workflow_class, **workflow.input) end end |
.send_event(event_type, data, metadata: nil) ⇒ Object
Send event to workflows
103 104 105 106 |
# File 'lib/shikibu.rb', line 103 def send_event(event_type, data, metadata: nil) ensure_app! app.send_event(event_type, data, metadata: ) end |
.status(instance_id) ⇒ Object
Get workflow status
91 92 93 94 |
# File 'lib/shikibu.rb', line 91 def status(instance_id) ensure_app! app.get_status(instance_id) end |
.workflow_registry ⇒ Object
Registry for workflow definitions
15 16 17 |
# File 'lib/shikibu.rb', line 15 def workflow_registry @workflow_registry ||= {} end |