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.
105 106 107 108 |
# File 'lib/temporalio/internal/bridge/worker.rb', line 105 def initialize(slot_supplier:, thread_pool:) @slot_supplier = slot_supplier @thread_pool = thread_pool end |
Instance Method Details
#mark_slot_used(context, &block) ⇒ Object
126 127 128 129 130 131 132 |
# File 'lib/temporalio/internal/bridge/worker.rb', line 126 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
134 135 136 137 138 139 140 |
# File 'lib/temporalio/internal/bridge/worker.rb', line 134 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
110 111 112 113 114 115 116 |
# File 'lib/temporalio/internal/bridge/worker.rb', line 110 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
118 119 120 121 122 123 124 |
# File 'lib/temporalio/internal/bridge/worker.rb', line 118 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 |