Class: Temporalio::Internal::Worker::ActivityWorker::RunningActivity

Inherits:
Activity::Context
  • Object
show all
Defined in:
lib/temporalio/internal/worker/activity_worker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Activity::Context

current, current_or_nil, exist?

Constructor Details

#initialize(worker:, info:, cancellation:, worker_shutdown_cancellation:, payload_converter:, logger:, runtime_metric_meter:) ⇒ RunningActivity

rubocop:disable Lint/MissingSuper



354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 354

def initialize( # rubocop:disable Lint/MissingSuper
  worker:,
  info:,
  cancellation:,
  worker_shutdown_cancellation:,
  payload_converter:,
  logger:,
  runtime_metric_meter:
)
  @worker = worker
  @info = info
  @cancellation = cancellation
  @cancellation_details = nil
  @worker_shutdown_cancellation = worker_shutdown_cancellation
  @payload_converter = payload_converter
  @logger = logger
  @runtime_metric_meter = runtime_metric_meter
  @_outbound_impl = nil
  @_server_requested_cancel = false
end

Instance Attribute Details

#_outbound_implObject

Returns the value of attribute _outbound_impl.



352
353
354
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 352

def _outbound_impl
  @_outbound_impl
end

#_server_requested_cancelObject (readonly)

Returns the value of attribute _server_requested_cancel.



350
351
352
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 350

def _server_requested_cancel
  @_server_requested_cancel
end

#cancellationObject (readonly)

Returns the value of attribute cancellation.



350
351
352
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 350

def cancellation
  @cancellation
end

#cancellation_detailsObject (readonly)

Returns the value of attribute cancellation_details.



350
351
352
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 350

def cancellation_details
  @cancellation_details
end

#infoObject (readonly)

Returns the value of attribute info.



350
351
352
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 350

def info
  @info
end

#instanceObject

Returns the value of attribute instance.



352
353
354
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 352

def instance
  @instance
end

#loggerObject (readonly)

Returns the value of attribute logger.



350
351
352
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 350

def logger
  @logger
end

#payload_converterObject (readonly)

Returns the value of attribute payload_converter.



350
351
352
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 350

def payload_converter
  @payload_converter
end

#worker_shutdown_cancellationObject (readonly)

Returns the value of attribute worker_shutdown_cancellation.



350
351
352
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 350

def worker_shutdown_cancellation
  @worker_shutdown_cancellation
end

Instance Method Details

#_cancel(reason:, details:) ⇒ Object



398
399
400
401
402
403
404
405
406
407
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 398

def _cancel(reason:, details:)
  # Do not issue cancel if already canceled
  return if @cancellation_details

  @_server_requested_cancel = true
  # Set the cancellation details _before_ issuing the cancel itself
  @cancellation_details = details
  _, cancel_proc = cancellation
  cancel_proc.call(reason:)
end

#clientObject



394
395
396
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 394

def client
  @worker.client
end

#heartbeat(*details) ⇒ Object



375
376
377
378
379
380
381
382
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 375

def heartbeat(*details)
  raise 'Implementation not set yet' if _outbound_impl.nil?

  # No-op if local
  return if info.local?

  _outbound_impl.heartbeat(Temporalio::Worker::Interceptor::Activity::HeartbeatInput.new(details:))
end

#metric_meterObject



384
385
386
387
388
389
390
391
392
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 384

def metric_meter
  @metric_meter ||= @runtime_metric_meter.with_additional_attributes(
    {
      namespace: info.workflow_namespace,
      task_queue: info.task_queue,
      activity_type: info.activity_type
    }
  )
end