forked from coinbase/temporal-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.rb
More file actions
39 lines (32 loc) · 998 Bytes
/
helpers.rb
File metadata and controls
39 lines (32 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require 'securerandom'
module Helpers
def run_workflow(workflow, *input, **args)
args[:options] = { workflow_id: SecureRandom.uuid }.merge(args[:options] || {})
run_id = Temporal.start_workflow(workflow, *input, **args)
[args[:options][:workflow_id], run_id]
end
def wait_for_workflow_completion(workflow_id, run_id)
fetch_history(
workflow_id,
run_id,
wait_for_new_event: true,
event_type: :close,
timeout: 15,
)
end
def fetch_history(workflow_id, run_id, options = {})
connection = Temporal.send(:default_client).send(:connection)
options = {
namespace: integration_spec_namespace,
workflow_id: workflow_id,
run_id: run_id,
}.merge(options)
connection.get_workflow_execution_history(**options)
end
def integration_spec_namespace
ENV.fetch('TEMPORAL_NAMESPACE', DEFAULT_NAMESPACE)
end
def integration_spec_task_queue
ENV.fetch('TEMPORAL_TASK_QUEUE', DEFAULT_TASK_QUEUE)
end
end