-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstarter.rb
More file actions
62 lines (53 loc) · 2.14 KB
/
starter.rb
File metadata and controls
62 lines (53 loc) · 2.14 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# frozen_string_literal: true
# We must require Temporal SDK first and set the env var to prevent Coinbase SDK from trying to load its protos
require 'temporalio/client'
require 'temporalio/env_config'
ENV['COINBASE_TEMPORAL_RUBY_DISABLE_PROTO_LOAD'] = '1'
require_relative 'coinbase_workflow'
require_relative 'temporal_workflow'
require 'logger'
require 'temporal-ruby'
# Load config and apply defaults
args, kwargs = Temporalio::EnvConfig::ClientConfig.load_client_connect_options
args[0] ||= 'localhost:7233' # Default address
args[1] ||= 'default' # Default namespace
# Create Temporal SDK client
client = Temporalio::Client.connect(*args, **kwargs)
# Run Coinbase workflow
result = client.execute_workflow(
CoinbaseRuby::CoinbaseWorkflow.name, 'user1',
id: 'coinbase-ruby-sample-workflow-id-1', task_queue: 'coinbase-ruby-sample-coinbase'
)
puts "Coinbase SDK workflow result from Temporal SDK client: #{result}"
# Run Temporal workflow
result = client.execute_workflow(
CoinbaseRuby::TemporalWorkflow, 'user2',
id: 'coinbase-ruby-sample-workflow-id-2', task_queue: 'coinbase-ruby-sample-temporal'
)
puts "Temporal SDK workflow result from Temporal SDK client: #{result}"
# Now do the same with Coinbase SDK, first configuring the client
Temporal.configure do |config|
config.host = 'localhost'
config.port = 7233
config.namespace = 'default'
end
# Run Coinbase workflow
run_id = Temporal.start_workflow(
CoinbaseRuby::CoinbaseWorkflow, 'user3',
options: { workflow_id: 'coinbase-ruby-sample-workflow-id-3', task_queue: 'coinbase-ruby-sample-coinbase' }
)
result = Temporal.await_workflow_result(
CoinbaseRuby::CoinbaseWorkflow,
workflow_id: 'coinbase-ruby-sample-workflow-id-3', run_id:
)
puts "Coinbase SDK workflow result from Coinbase SDK client: #{result}"
# Run Temporal workflow
run_id = Temporal.start_workflow(
:TemporalWorkflow, 'user4',
options: { workflow_id: 'coinbase-ruby-sample-workflow-id-4', task_queue: 'coinbase-ruby-sample-temporal' }
)
result = Temporal.await_workflow_result(
:TemporalWorkflow,
workflow_id: 'coinbase-ruby-sample-workflow-id-4', run_id:
)
puts "Temporal SDK workflow result from Coinbase SDK client: #{result}"