Skip to content

Commit 8e91451

Browse files
committed
Review comments
1 parent 6071f34 commit 8e91451

8 files changed

Lines changed: 23 additions & 26 deletions

File tree

temporalio/lib/temporalio/activity.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require 'temporalio/activity/context'
55
require 'temporalio/activity/definition'
66
require 'temporalio/activity/info'
7+
require 'temporalio/priority'
78

89
module Temporalio
910
# All activity related classes.

temporalio/lib/temporalio/activity/info.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module Activity
4040
# @!attribute local?
4141
# @return [Boolean] Whether the activity is a local activity or not.
4242
# @!attribute priority
43-
# @return [Priority, nil] The priority of this activity.
43+
# @return [Priority] The priority of this activity.
4444
# @!attribute schedule_to_close_timeout
4545
# @return [Float, nil] Schedule to close timeout set by the caller.
4646
# @!attribute scheduled_time

temporalio/lib/temporalio/client/interceptor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def intercept_client(next_interceptor)
3737
:start_delay,
3838
:request_eager_start,
3939
:headers,
40-
:priority,
4140
:versioning_override,
41+
:priority,
4242
:rpc_options
4343
)
4444

temporalio/lib/temporalio/internal/client/implementation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def start_workflow(input)
7070
input.static_summary, input.static_details, @client.data_converter
7171
),
7272
header: ProtoUtils.headers_to_proto(input.headers, @client.data_converter),
73-
priority: input.priority&._to_proto,
73+
priority: input.priority._to_proto,
7474
versioning_override: input.versioning_override&._to_proto
7575
)
7676

temporalio/lib/temporalio/internal/worker/workflow_instance/outbound_implementation.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def execute_activity(input)
7474
retry_policy: input.retry_policy&._to_proto,
7575
cancellation_type: input.cancellation_type,
7676
do_not_eagerly_execute: input.disable_eager_execution,
77-
priority: input.priority&._to_proto
77+
priority: input.priority._to_proto
7878
),
7979
user_metadata: ProtoUtils.to_user_metadata(input.summary, nil, @instance.payload_converter)
8080
)
@@ -339,7 +339,7 @@ def start_child_workflow(input)
339339
memo: ProtoUtils.memo_to_proto_hash(input.memo, @instance.payload_converter),
340340
search_attributes: input.search_attributes&._to_proto_hash,
341341
cancellation_type: input.cancellation_type,
342-
priority: input.priority&._to_proto
342+
priority: input.priority._to_proto
343343
),
344344
user_metadata: ProtoUtils.to_user_metadata(
345345
input.static_summary, input.static_details, @instance.payload_converter

temporalio/lib/temporalio/priority.rb

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
require 'temporalio/api'
44

55
module Temporalio
6+
Priority = Data.define(
7+
:priority_key
8+
)
9+
610
# Priority contains metadata that controls relative ordering of task processing when tasks are
711
# backlogged in a queue. Initially, Priority will be used in activity and workflow task
812
# queues, which are typically where backlogs exist. Priority is (for now) attached to
@@ -15,19 +19,17 @@ module Temporalio
1519
# The overall semantics of Priority are:
1620
# 1. First, consider "priority_key": lower number goes first.
1721
# (more will be added here later).
22+
#
23+
# @!attribute priority_key
24+
# @return [Integer, nil] The priority key, which is a positive integer from 1 to n, where
25+
# smaller integers correspond to higher priorities (tasks run sooner). In general, tasks in a
26+
# queue should be processed in close to priority order, although small deviations are possible.
27+
# The maximum priority value (minimum priority) is determined by server configuration, and
28+
# defaults to 5.
29+
#
30+
# The default priority is (min+max)/2. With the default max of 5 and min of 1, that comes
31+
# out to 3.
1832
class Priority
19-
# The priority key, which is a positive integer from 1 to n, where smaller integers
20-
# correspond to higher priorities (tasks run sooner). In general, tasks in a queue should
21-
# be processed in close to priority order, although small deviations are possible. The
22-
# maximum priority value (minimum priority) is determined by server configuration, and
23-
# defaults to 5.
24-
#
25-
# The default priority is (min+max)/2. With the default max of 5 and min of 1, that comes
26-
# out to 3.
27-
#
28-
# @return [Integer, nil] The priority key
29-
attr_reader :priority_key
30-
3133
# @!visibility private
3234
def self._from_proto(priority)
3335
return default if priority.nil?
@@ -39,14 +41,7 @@ def self._from_proto(priority)
3941
#
4042
# @return [Priority] The default priority
4143
def self.default
42-
@default ||= new
43-
end
44-
45-
# Create a new Priority instance
46-
#
47-
# @param priority_key [Integer, nil] The priority key
48-
def initialize(priority_key: nil)
49-
@priority_key = priority_key
44+
@default ||= new(priority_key: nil)
5045
end
5146

5247
# @!visibility private

temporalio/lib/temporalio/workflow.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require 'random/formatter'
44
require 'temporalio/error'
5+
require 'temporalio/priority'
56
require 'temporalio/workflow/activity_cancellation_type'
67
require 'temporalio/workflow/child_workflow_cancellation_type'
78
require 'temporalio/workflow/child_workflow_handle'

temporalio/lib/temporalio/workflow/info.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module Workflow
4646
# @!attribute parent
4747
# @return [ParentInfo, nil] Parent information for the workflow if this is a child.
4848
# @!attribute priority
49-
# @return [Priority, nil] The priority of this workflow.
49+
# @return [Priority] The priority of this workflow.
5050
# @!attribute retry_policy
5151
# @return [RetryPolicy, nil] Retry policy for the workflow.
5252
# @!attribute root

0 commit comments

Comments
 (0)