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.



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

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

Instance Method Details

#mark_slot_used(context, &block) ⇒ Object



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

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



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

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



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

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



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

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