Class: Temporalio::Internal::Bridge::Worker::CustomSlotSupplier
- Inherits:
-
Object
- Object
- Temporalio::Internal::Bridge::Worker::CustomSlotSupplier
- Defined in:
- lib/temporalio/internal/bridge/worker.rb
Instance Method Summary collapse
-
#initialize(slot_supplier:, thread_pool:) ⇒ CustomSlotSupplier
constructor
A new instance of CustomSlotSupplier.
- #mark_slot_used(context, &block) ⇒ Object
- #release_slot(context, &block) ⇒ Object
- #reserve_slot(context, cancellation, &block) ⇒ Object
- #try_reserve_slot(context, &block) ⇒ Object
Constructor Details
#initialize(slot_supplier:, thread_pool:) ⇒ CustomSlotSupplier
Returns a new instance of CustomSlotSupplier.
109 110 111 112 |
# File 'lib/temporalio/internal/bridge/worker.rb', line 109 def initialize(slot_supplier:, thread_pool:) @slot_supplier = slot_supplier @thread_pool = thread_pool end |
Instance Method Details
#mark_slot_used(context, &block) ⇒ Object
130 131 132 133 134 135 136 |
# File 'lib/temporalio/internal/bridge/worker.rb', line 130 def mark_slot_used(context, &block) run_user_code do block.call(@slot_supplier.mark_slot_used(context)) rescue Exception => e # rubocop:disable Lint/RescueException block.call(e) end end |
#release_slot(context, &block) ⇒ Object
138 139 140 141 142 143 144 |
# File 'lib/temporalio/internal/bridge/worker.rb', line 138 def release_slot(context, &block) run_user_code do block.call(@slot_supplier.release_slot(context)) rescue Exception => e # rubocop:disable Lint/RescueException block.call(e) end end |
#reserve_slot(context, cancellation, &block) ⇒ Object
114 115 116 117 118 119 120 |
# File 'lib/temporalio/internal/bridge/worker.rb', line 114 def reserve_slot(context, cancellation, &block) run_user_code do @slot_supplier.reserve_slot(context, cancellation) { |v| block.call(v) } rescue Exception => e # rubocop:disable Lint/RescueException block.call(e) end end |
#try_reserve_slot(context, &block) ⇒ Object
122 123 124 125 126 127 128 |
# File 'lib/temporalio/internal/bridge/worker.rb', line 122 def try_reserve_slot(context, &block) run_user_code do block.call(@slot_supplier.try_reserve_slot(context)) rescue Exception => e # rubocop:disable Lint/RescueException block.call(e) end end |