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



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

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.



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

def _outbound_impl
  @_outbound_impl
end

#_server_requested_cancelObject (readonly)

Returns the value of attribute _server_requested_cancel.



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

def _server_requested_cancel
  @_server_requested_cancel
end

#cancellationObject (readonly)

Returns the value of attribute cancellation.



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

def cancellation
  @cancellation
end

#cancellation_detailsObject (readonly)

Returns the value of attribute cancellation_details.



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

def cancellation_details
  @cancellation_details
end

#infoObject (readonly)

Returns the value of attribute info.



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

def info
  @info
end

#instanceObject

Returns the value of attribute instance.



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

def instance
  @instance
end

#loggerObject (readonly)

Returns the value of attribute logger.



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

def logger
  @logger
end

#payload_converterObject (readonly)

Returns the value of attribute payload_converter.



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

def payload_converter
  @payload_converter
end

#worker_shutdown_cancellationObject (readonly)

Returns the value of attribute worker_shutdown_cancellation.



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

def worker_shutdown_cancellation
  @worker_shutdown_cancellation
end

Instance Method Details

#_cancel(reason:, details:) ⇒ Object



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

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



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

def client
  @worker.client
end

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



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

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



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

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