Class: Temporalio::Worker::Tuner
- Inherits:
-
Object
- Object
- Temporalio::Worker::Tuner
- Defined in:
- lib/temporalio/worker/tuner.rb
Overview
Worker tuner that allows for dynamic customization of some aspects of worker configuration.
Defined Under Namespace
Classes: ResourceBasedSlotOptions, ResourceBasedTunerOptions, SlotSupplier
Instance Attribute Summary collapse
-
#activity_slot_supplier ⇒ SlotSupplier
readonly
Slot supplier for activities.
-
#local_activity_slot_supplier ⇒ SlotSupplier
readonly
Slot supplier for local activities.
-
#workflow_slot_supplier ⇒ SlotSupplier
readonly
Slot supplier for workflows.
Class Method Summary collapse
-
.create_fixed(workflow_slots: 100, activity_slots: 100, local_activity_slots: 100) ⇒ Tuner
Create a fixed-size tuner with the provided number of slots.
-
.create_resource_based(target_memory_usage:, target_cpu_usage:, workflow_options: ResourceBasedSlotOptions.new(min_slots: 5, max_slots: 500, ramp_throttle: 0.0), activity_options: ResourceBasedSlotOptions.new(min_slots: 1, max_slots: 500, ramp_throttle: 0.05), local_activity_options: ResourceBasedSlotOptions.new(min_slots: 1, max_slots: 500, ramp_throttle: 0.05)) ⇒ Tuner
Create a resource-based tuner with the provided options.
Instance Method Summary collapse
-
#initialize(workflow_slot_supplier:, activity_slot_supplier:, local_activity_slot_supplier:) ⇒ Tuner
constructor
Create a tuner from 3 slot suppliers.
Constructor Details
#initialize(workflow_slot_supplier:, activity_slot_supplier:, local_activity_slot_supplier:) ⇒ Tuner
Create a tuner from 3 slot suppliers.
140 141 142 143 144 145 146 147 148 |
# File 'lib/temporalio/worker/tuner.rb', line 140 def initialize( workflow_slot_supplier:, activity_slot_supplier:, local_activity_slot_supplier: ) @workflow_slot_supplier = workflow_slot_supplier @activity_slot_supplier = activity_slot_supplier @local_activity_slot_supplier = local_activity_slot_supplier end |
Instance Attribute Details
#activity_slot_supplier ⇒ SlotSupplier (readonly)
Returns Slot supplier for activities.
130 131 132 |
# File 'lib/temporalio/worker/tuner.rb', line 130 def activity_slot_supplier @activity_slot_supplier end |
#local_activity_slot_supplier ⇒ SlotSupplier (readonly)
Returns Slot supplier for local activities.
133 134 135 |
# File 'lib/temporalio/worker/tuner.rb', line 133 def local_activity_slot_supplier @local_activity_slot_supplier end |
#workflow_slot_supplier ⇒ SlotSupplier (readonly)
Returns Slot supplier for workflows.
127 128 129 |
# File 'lib/temporalio/worker/tuner.rb', line 127 def workflow_slot_supplier @workflow_slot_supplier end |
Class Method Details
.create_fixed(workflow_slots: 100, activity_slots: 100, local_activity_slots: 100) ⇒ Tuner
Create a fixed-size tuner with the provided number of slots.
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/temporalio/worker/tuner.rb', line 81 def self.create_fixed( workflow_slots: 100, activity_slots: 100, local_activity_slots: 100 ) new( workflow_slot_supplier: SlotSupplier::Fixed.new(workflow_slots), activity_slot_supplier: SlotSupplier::Fixed.new(activity_slots), local_activity_slot_supplier: SlotSupplier::Fixed.new(local_activity_slots) ) end |
.create_resource_based(target_memory_usage:, target_cpu_usage:, workflow_options: ResourceBasedSlotOptions.new(min_slots: 5, max_slots: 500, ramp_throttle: 0.0), activity_options: ResourceBasedSlotOptions.new(min_slots: 1, max_slots: 500, ramp_throttle: 0.05), local_activity_options: ResourceBasedSlotOptions.new(min_slots: 1, max_slots: 500, ramp_throttle: 0.05)) ⇒ Tuner
Create a resource-based tuner with the provided options.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/temporalio/worker/tuner.rb', line 105 def self.create_resource_based( target_memory_usage:, target_cpu_usage:, workflow_options: ResourceBasedSlotOptions.new(min_slots: 5, max_slots: 500, ramp_throttle: 0.0), activity_options: ResourceBasedSlotOptions.new(min_slots: 1, max_slots: 500, ramp_throttle: 0.05), local_activity_options: ResourceBasedSlotOptions.new(min_slots: 1, max_slots: 500, ramp_throttle: 0.05) ) = ResourceBasedTunerOptions.new(target_memory_usage:, target_cpu_usage:) new( workflow_slot_supplier: SlotSupplier::ResourceBased.new( tuner_options:, slot_options: ), activity_slot_supplier: SlotSupplier::ResourceBased.new( tuner_options:, slot_options: ), local_activity_slot_supplier: SlotSupplier::ResourceBased.new( tuner_options:, slot_options: ) ) end |