Class: Temporalio::Internal::Bridge::Worker::CustomSlotSupplier

Inherits:
Object
  • Object
show all
Defined in:
lib/temporalio/internal/bridge/worker.rb

Instance Method Summary collapse

Constructor Details

#initialize(slot_supplier:, thread_pool:) ⇒ CustomSlotSupplier

Returns a new instance of CustomSlotSupplier.



110
111
112
113
# File 'lib/temporalio/internal/bridge/worker.rb', line 110

def initialize(slot_supplier:, thread_pool:)
  @slot_supplier = slot_supplier
  @thread_pool = thread_pool
end

Instance Method Details

#mark_slot_used(context, &block) ⇒ Object



131
132
133
134
135
136
137
# File 'lib/temporalio/internal/bridge/worker.rb', line 131

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



139
140
141
142
143
144
145
# File 'lib/temporalio/internal/bridge/worker.rb', line 139

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



115
116
117
118
119
120
121
# File 'lib/temporalio/internal/bridge/worker.rb', line 115

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



123
124
125
126
127
128
129
# File 'lib/temporalio/internal/bridge/worker.rb', line 123

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