-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathworker.rb
More file actions
34 lines (29 loc) · 1.09 KB
/
worker.rb
File metadata and controls
34 lines (29 loc) · 1.09 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
# frozen_string_literal: true
# @@@SNIPSTART money-transfer-project-template-ruby-worker
require_relative 'activities'
require_relative 'shared'
require_relative 'workflow'
require 'logger'
require 'temporalio/client'
require 'temporalio/worker'
# Create a Temporal Client that connects to a local Temporal Service, uses
# a Namespace called 'default', and displays log messages to standard output
client = Temporalio::Client.connect(
'localhost:7233',
'default',
logger: Logger.new($stdout, level: Logger::INFO)
)
# Create a Worker that polls the specified Task Queue and can
# fulfill requests for the specified Workflow and Activities
worker = Temporalio::Worker.new(
client:,
task_queue: MoneyTransfer::TASK_QUEUE_NAME,
workflows: [MoneyTransfer::MoneyTransferWorkflow],
activities: [MoneyTransfer::BankActivities::Withdraw,
MoneyTransfer::BankActivities::Deposit,
MoneyTransfer::BankActivities::Refund]
)
# Start the Worker, which will poll the Task Queue until stopped
puts 'Starting Worker (press Ctrl+C to exit)'
worker.run(shutdown_signals: ['SIGINT'])
# @@@SNIPEND