-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathrun.rb
More file actions
36 lines (30 loc) · 1.03 KB
/
run.rb
File metadata and controls
36 lines (30 loc) · 1.03 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
# frozen_string_literal: true
require 'securerandom'
require 'temporalio/client'
require 'temporalio/env_config'
require 'temporalio/worker'
require_relative 'eager_workflow'
require_relative 'greeting_activity'
TASK_QUEUE = 'eager-workflow-start-sample'
# Note that the worker and client run in the same process and share the same client connection
args, kwargs = Temporalio::EnvConfig::ClientConfig.load_client_connect_options
args[0] ||= 'localhost:7233' # Default address
args[1] ||= 'default' # Default namespace
client = Temporalio::Client.connect(*args, **kwargs)
worker = Temporalio::Worker.new(
client:,
task_queue: TASK_QUEUE,
workflows: [EagerWorkflowStart::EagerWorkflow],
activities: [EagerWorkflowStart::GreetingActivity]
)
# Run worker in the background while we start the workflow
worker.run do
handle = client.start_workflow(
EagerWorkflowStart::EagerWorkflow,
'Temporal',
id: 'eager-workflow-start-sample-workflow-id',
task_queue: TASK_QUEUE,
request_eager_start: true
)
puts handle.result
end