Class: Temporalio::Internal::Worker::WorkflowWorker::State

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workflow_definitions:, bridge_worker:, logger:, metric_meter:, data_converter:, deadlock_timeout:, illegal_calls:, namespace:, task_queue:, disable_eager_activity_execution:, workflow_interceptors:, workflow_failure_exception_types:, unsafe_workflow_io_enabled:, patch_activation_callback:, assert_valid_local_activity:) ⇒ State



399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 399

def initialize(
  workflow_definitions:, bridge_worker:, logger:, metric_meter:, data_converter:, deadlock_timeout:,
  illegal_calls:, namespace:, task_queue:, disable_eager_activity_execution:,
  workflow_interceptors:, workflow_failure_exception_types:, unsafe_workflow_io_enabled:,
  patch_activation_callback:, assert_valid_local_activity:
)
  @workflow_definitions = workflow_definitions
  @bridge_worker = bridge_worker
  @logger = logger
  @metric_meter = metric_meter
  @data_converter = data_converter
  @deadlock_timeout = deadlock_timeout
  @illegal_calls = illegal_calls
  @namespace = namespace
  @task_queue = task_queue
  @disable_eager_activity_execution = disable_eager_activity_execution
  @workflow_interceptors = workflow_interceptors
  @workflow_failure_exception_types = workflow_failure_exception_types
  @unsafe_workflow_io_enabled = unsafe_workflow_io_enabled
  @patch_activation_callback = patch_activation_callback
  @assert_valid_local_activity = assert_valid_local_activity

  @running_workflows = {}
  @running_workflows_mutex = Mutex.new
end

Instance Attribute Details

#assert_valid_local_activity ⇒ Object (readonly)

Returns the value of attribute assert_valid_local_activity.



392
393
394
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 392

def assert_valid_local_activity
  @assert_valid_local_activity
end

#bridge_worker ⇒ Object (readonly)

Returns the value of attribute bridge_worker.



392
393
394
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 392

def bridge_worker
  @bridge_worker
end

#data_converter ⇒ Object (readonly)

Returns the value of attribute data_converter.



392
393
394
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 392

def data_converter
  @data_converter
end

#deadlock_timeout ⇒ Object (readonly)

Returns the value of attribute deadlock_timeout.



392
393
394
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 392

def deadlock_timeout
  @deadlock_timeout
end

#disable_eager_activity_execution ⇒ Object (readonly)

Returns the value of attribute disable_eager_activity_execution.



392
393
394
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 392

def disable_eager_activity_execution
  @disable_eager_activity_execution
end

#illegal_calls ⇒ Object (readonly)

Returns the value of attribute illegal_calls.



392
393
394
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 392

def illegal_calls
  @illegal_calls
end

#logger ⇒ Object (readonly)

Returns the value of attribute logger.



392
393
394
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 392

def logger
  @logger
end

#metric_meter ⇒ Object (readonly)

Returns the value of attribute metric_meter.



392
393
394
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 392

def metric_meter
  @metric_meter
end

#namespace ⇒ Object (readonly)

Returns the value of attribute namespace.



392
393
394
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 392

def namespace
  @namespace
end

#on_eviction=(value) ⇒ Object (writeonly)

Sets the attribute on_eviction



397
398
399
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 397

def on_eviction=(value)
  @on_eviction = value
end

#patch_activation_callback ⇒ Object (readonly)

Returns the value of attribute patch_activation_callback.



392
393
394
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 392

def patch_activation_callback
  @patch_activation_callback
end

#task_queue ⇒ Object (readonly)

Returns the value of attribute task_queue.



392
393
394
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 392

def task_queue
  @task_queue
end

#unsafe_workflow_io_enabled ⇒ Object (readonly)

Returns the value of attribute unsafe_workflow_io_enabled.



392
393
394
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 392

def unsafe_workflow_io_enabled
  @unsafe_workflow_io_enabled
end

#workflow_definitions ⇒ Object (readonly)

Returns the value of attribute workflow_definitions.



392
393
394
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 392

def workflow_definitions
  @workflow_definitions
end

#workflow_failure_exception_types ⇒ Object (readonly)

Returns the value of attribute workflow_failure_exception_types.



392
393
394
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 392

def workflow_failure_exception_types
  @workflow_failure_exception_types
end

#workflow_interceptors ⇒ Object (readonly)

Returns the value of attribute workflow_interceptors.



392
393
394
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 392

def workflow_interceptors
  @workflow_interceptors
end

Instance Method Details

#evict_all ⇒ Object



445
446
447
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 445

def evict_all
  @running_workflows_mutex.synchronize { @running_workflows.clear }
end

#evict_running_workflow(run_id, cache_remove_job) ⇒ Object



440
441
442
443
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 440

def evict_running_workflow(run_id, cache_remove_job)
  @running_workflows_mutex.synchronize { @running_workflows.delete(run_id) }
  @on_eviction&.call(run_id, cache_remove_job)
end

#get_or_create_running_workflow(run_id) ⇒ Object

This can never be called at the same time for the same run ID on the same state object



426
427
428
429
430
431
432
433
434
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 426

def get_or_create_running_workflow(run_id, &)
  instance = @running_workflows_mutex.synchronize { @running_workflows[run_id] }
  # If instance is not there, we create it out of lock then store it under lock
  unless instance
    instance = yield
    @running_workflows_mutex.synchronize { @running_workflows[run_id] = instance }
  end
  instance
end

#running_workflow_info(run_id) ⇒ Object



436
437
438
# File 'lib/temporalio/internal/worker/workflow_worker.rb', line 436

def running_workflow_info(run_id)
  @running_workflows_mutex.synchronize { @running_workflows[run_id] }&.info
end