Module: ActiveJob::Temporal::Adapter
- Defined in:
- lib/activejob/temporal/adapter.rb
Overview
Helper methods for the TemporalAdapter.
This module provides utility functions for building workflow IDs and resolving task queue names. Used internally by the adapter.
Class Method Summary collapse
-
.build_workflow_id(job) ⇒ String
Builds deterministic workflow ID used for Temporal workflows.
-
.resolve_task_queue(job, config: ActiveJob::Temporal.config) ⇒ String
Resolves the Temporal task queue name for a given job.
Class Method Details
.build_workflow_id(job) ⇒ String
Idempotency Guarantee The workflow ID format ensures that jobs with the same job_id will never execute twice. This is critical for preventing duplicate processing in distributed systems.
Builds deterministic workflow ID used for Temporal workflows.
Delegates ID construction to WorkflowIdBuilder while preserving the public helper used by integrations and tests. Creates a unique, reproducible workflow ID from the job class and job ID. This enables idempotent enqueuing: duplicate enqueue calls with the same job_id will be rejected by Temporal’s FAIL conflict policy.
42 43 44 |
# File 'lib/activejob/temporal/adapter.rb', line 42 def build_workflow_id(job) WorkflowIdBuilder.new(configured_workflow_id_generator).build(job) end |
.resolve_task_queue(job, config: ActiveJob::Temporal.config) ⇒ String
Resolves the Temporal task queue name for a given job.
Extracts the queue name from the job and applies the configured task_queue_prefix if present. Defaults to “default” if queue_name is blank.
65 66 67 68 69 70 71 72 73 |
# File 'lib/activejob/temporal/adapter.rb', line 65 def resolve_task_queue(job, config: ActiveJob::Temporal.config) queue_name = priority_task_queue(job, config) || job.queue_name.to_s.strip queue_name = "default" if queue_name.empty? prefix = config.task_queue_prefix return queue_name if prefix.nil? || prefix.to_s.strip.empty? "#{prefix}#{queue_name}" end |