33require 'temporalio/api'
44
55module 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
0 commit comments