Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
cduanfigma authored Jul 17, 2024
2 parents 34f3a94 + 5d12aa3 commit 49a2063
Show file tree
Hide file tree
Showing 24 changed files with 925 additions and 39 deletions.
4 changes: 2 additions & 2 deletions examples/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source 'https://rubygems.org'

gem 'temporal-ruby', path: '../'

gem 'dry-types', '>= 1.2.0'
gem 'dry-struct', '~> 1.1.1'
gem 'dry-types', '>= 1.7.2'
gem 'dry-struct', '~> 1.6.0'

gem 'rspec', group: :test
51 changes: 51 additions & 0 deletions examples/bin/update_replay_test_histories
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env ruby

# This script regenerates the workflow history files used in the example replay tests
# under examples/spec/replay/histories. It starts the necessary workflow, sends some
# signals, awaits workflow completion, then collects the history into JSON and protobuf
# binary file formats.
#
# To use this, start your Temporal server and bin/worker first. This script can then
# be run without any arguments. It will overwrite existing history files in the tree.
#
# NOTE: By default, collected history files contain the host names of the machines
# where the worker and this script are run because the default identity is pid@hostname.
# If you'd like, you can override this by setting an identity in the configuration in
# init.rb.

require_relative "../init"
require_relative "../workflows/signal_with_start_workflow"

workflow_id = SecureRandom.uuid
run_id = Temporal.start_workflow(
SignalWithStartWorkflow,
"hit",
options: {
workflow_id: workflow_id,
timeouts: {
execution: 30
},
signal_name: "miss",
signal_input: 1
}
)
Temporal.logger.info("Started workflow", {workflow_id: workflow_id, run_id: run_id})
sleep(1)
Temporal.signal_workflow(SignalWithStartWorkflow, "miss", workflow_id, run_id, 2)
sleep(1)
Temporal.signal_workflow(SignalWithStartWorkflow, "hit", workflow_id, run_id, 3)
Temporal.await_workflow_result(SignalWithStartWorkflow, workflow_id: workflow_id, run_id: run_id)

# Save in JSON, exactly like would be downloaded from Temporal UI
history_json = Temporal.get_workflow_history_json(workflow_id: workflow_id, run_id: run_id)
filename = File.expand_path("../spec/replay/histories/signal_with_start.json", File.dirname(__FILE__))
File.open(filename, "w") do |f|
f.write(history_json)
end

# Save in protobuf binary format
history_binary = Temporal.get_workflow_history_protobuf(workflow_id: workflow_id, run_id: run_id)
filename = File.expand_path("../spec/replay/histories/signal_with_start.protobin", File.dirname(__FILE__))
File.open(filename, "wb") do |f|
f.write(history_binary)
end
2 changes: 1 addition & 1 deletion examples/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.5'

services:
temporal:
image: temporalio/auto-setup:latest
image: temporalio/auto-setup:1.22.0
ports:
- "7233:7233"
environment:
Expand Down
Binary file not shown.
Loading

0 comments on commit 49a2063

Please sign in to comment.