Class: Hatchet::DesiredWorkerLabel
- Inherits:
-
Object
- Object
- Hatchet::DesiredWorkerLabel
- Defined in:
- lib/hatchet/labels.rb
Overview
Defines a desired worker label for task scheduling affinity
Instance Attribute Summary collapse
-
#comparator ⇒ Symbol
readonly
Comparator for numeric values.
-
#required ⇒ Boolean
readonly
Whether this label is required (hard constraint).
-
#value ⇒ String, Integer
readonly
The desired label value.
-
#weight ⇒ Integer
readonly
Weight for soft scheduling preferences (higher = stronger preference).
Instance Method Summary collapse
-
#initialize(value:, weight: 1, required: false, comparator: :equal) ⇒ DesiredWorkerLabel
constructor
A new instance of DesiredWorkerLabel.
- #to_h ⇒ Hash
Constructor Details
#initialize(value:, weight: 1, required: false, comparator: :equal) ⇒ DesiredWorkerLabel
Returns a new instance of DesiredWorkerLabel.
38 39 40 41 42 43 |
# File 'lib/hatchet/labels.rb', line 38 def initialize(value:, weight: 1, required: false, comparator: :equal) @value = value @weight = weight @required = required @comparator = comparator end |
Instance Attribute Details
#comparator ⇒ Symbol (readonly)
Returns Comparator for numeric values.
32 33 34 |
# File 'lib/hatchet/labels.rb', line 32 def comparator @comparator end |
#required ⇒ Boolean (readonly)
Returns Whether this label is required (hard constraint).
29 30 31 |
# File 'lib/hatchet/labels.rb', line 29 def required @required end |
#value ⇒ String, Integer (readonly)
Returns The desired label value.
23 24 25 |
# File 'lib/hatchet/labels.rb', line 23 def value @value end |
#weight ⇒ Integer (readonly)
Returns Weight for soft scheduling preferences (higher = stronger preference).
26 27 28 |
# File 'lib/hatchet/labels.rb', line 26 def weight @weight end |
Instance Method Details
#to_h ⇒ Hash
46 47 48 49 50 51 52 53 |
# File 'lib/hatchet/labels.rb', line 46 def to_h { value: @value, weight: @weight, required: @required, comparator: @comparator.to_s.upcase, } end |