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