Skip to content

Commit 6948b92

Browse files
committed
Fix priority initter
1 parent 888864f commit 6948b92

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

temporalio/lib/temporalio/priority.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ def self.default
7272
@default ||= new(priority_key: nil, fairness_key: nil, fairness_weight: nil)
7373
end
7474

75+
# Initialize a new Priority instance.
76+
#
77+
# @param priority_key [Integer] The priority key
78+
# @param fairness_key [String, nil] The fairness key
79+
# @param fairness_weight [Float, nil] The fairness weight
80+
def initialize(priority_key:, fairness_key: nil, fairness_weight: nil)
81+
super
82+
end
83+
7584
# @!visibility private
7685
def _to_proto
7786
return nil if empty?

temporalio/test/worker_workflow_priority_test.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,23 @@ def test_workflow_priority
141141
assert_in_delta 0.2, priority.fairness_weight, 0.001
142142
end
143143
end
144+
145+
# Test with only priority & no fairness
146+
execute_workflow(
147+
WorkflowUsingPriorities, 5, true, nil, nil,
148+
activities: [ActivityWithPriority],
149+
priority: Temporalio::Priority.new(priority_key: 5, fairness_key: nil, fairness_weight: nil)
150+
) do |handle|
151+
assert_equal 'Done!', handle.result
152+
153+
handle.fetch_history_events.each do |event|
154+
next unless event.workflow_execution_started_event_attributes
155+
156+
priority = event.workflow_execution_started_event_attributes.priority
157+
assert_equal 5, priority.priority_key
158+
assert_equal "", priority.fairness_key
159+
assert_equal 0.0, priority.fairness_weight
160+
end
161+
end
144162
end
145163
end

0 commit comments

Comments
 (0)