Class: Temporalio::Worker::Tuner::SlotSupplier::Custom
- Inherits:
-
SlotSupplier
- Object
- SlotSupplier
- Temporalio::Worker::Tuner::SlotSupplier::Custom
- Defined in:
- lib/temporalio/worker/tuner.rb
Overview
A slot supplier that has callbacks invoked to handle slot supplying.
Users should be cautious when implementing this and make sure it is heavily tested and the documentation for every method is well understood.
Defined Under Namespace
Modules: SlotInfo Classes: MarkUsedContext, ReleaseContext, ReserveContext
Instance Method Summary collapse
-
#mark_slot_used(context) ⇒ Object
Mark a slot as used.
-
#release_slot(context) ⇒ Object
Release a previously reserved slot.
-
#reserve_slot(context, cancellation) {|Object| ... } ⇒ Object
Reserve a slot.
-
#try_reserve_slot(context) ⇒ Object?
Try to reserve a slot.
Instance Method Details
#mark_slot_used(context) ⇒ Object
WARNING: This should never block, this should return immediately.
WARNING: This call should never raise an exception. Any exception raised is ignored.
Mark a slot as used.
Due to the nature of Temporal polling, slots are reserved before they are used and may never get used. This call is made as just a notification when a slot is actually used.
162 163 164 |
# File 'lib/temporalio/worker/tuner.rb', line 162 def mark_slot_used(context) raise NotImplementedError end |
#release_slot(context) ⇒ Object
WARNING: This should never block, this should return immediately.
WARNING: This call should never raise an exception. Any exception raised is ignored.
Release a previously reserved slot.
173 174 175 |
# File 'lib/temporalio/worker/tuner.rb', line 173 def release_slot(context) raise NotImplementedError end |
#reserve_slot(context, cancellation) {|Object| ... } ⇒ Object
WARNING: This call should never raise an exception. Any exception raised is ignored and this is called again after 1 second.
Reserve a slot.
This can/should block and must provide the permit to the (code) block. The permit is any object (including nil) that will be given on the context for mark_slot_used and release_slot.
Just returning from this call is not enough to reserve the slot, a permit must be provided to the block (e.g. via yield or block.call). If the call completes, the system will still wait on the block (so this can be backgrounded by passing the block to something else). Reservations may be canceled via the given cancellation. Users can do things like add_cancel_callback, but it is very important that the code in the callback is fast as it is run on the same reactor thread as many other Temporal Ruby worker calls.
133 134 135 |
# File 'lib/temporalio/worker/tuner.rb', line 133 def reserve_slot(context, cancellation, &) raise NotImplementedError end |
#try_reserve_slot(context) ⇒ Object?
WARNING: This should never block, this should return immediately with a permit, or nil if the reservation could not occur.
WARNING: This call should never raise an exception. Any exception raised is ignored and the slot reservation attempt fails (i.e. same as if this method returned nil).
Try to reserve a slot.
148 149 150 |
# File 'lib/temporalio/worker/tuner.rb', line 148 def try_reserve_slot(context) raise NotImplementedError end |