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



362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 362

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.



360
361
362
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 360

def _outbound_impl
  @_outbound_impl
end

#_server_requested_cancelObject (readonly)

Returns the value of attribute _server_requested_cancel.



358
359
360
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 358

def _server_requested_cancel
  @_server_requested_cancel
end

#cancellationObject (readonly)

Returns the value of attribute cancellation.



358
359
360
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 358

def cancellation
  @cancellation
end

#cancellation_detailsObject (readonly)

Returns the value of attribute cancellation_details.



358
359
360
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 358

def cancellation_details
  @cancellation_details
end

#infoObject (readonly)

Returns the value of attribute info.



358
359
360
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 358

def info
  @info
end

#instanceObject

Returns the value of attribute instance.



360
361
362
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 360

def instance
  @instance
end

#loggerObject (readonly)

Returns the value of attribute logger.



358
359
360
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 358

def logger
  @logger
end

#payload_converterObject (readonly)

Returns the value of attribute payload_converter.



358
359
360
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 358

def payload_converter
  @payload_converter
end

#worker_shutdown_cancellationObject (readonly)

Returns the value of attribute worker_shutdown_cancellation.



358
359
360
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 358

def worker_shutdown_cancellation
  @worker_shutdown_cancellation
end

Instance Method Details

#_cancel(reason:, details:) ⇒ Object



408
409
410
411
412
413
414
415
416
417
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 408

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



404
405
406
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 404

def client
  @worker.client
end

#heartbeat(*details, detail_hints: nil) ⇒ Object



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

def heartbeat(*details, detail_hints: nil)
  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:, detail_hints:)
  )
end

#metric_meterObject



394
395
396
397
398
399
400
401
402
# File 'lib/temporalio/internal/worker/activity_worker.rb', line 394

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