Class: ActiveJob::Temporal::Configuration Private

Inherits:
Object
  • Object
show all
Defined in:
lib/activejob/temporal/configuration.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Note:

Thread Safety The global configuration object is synchronized by Configurable. Configure blocks mutate a candidate copy that replaces the active configuration only after validation succeeds.

Note:

Environment Variable Defaults ACTIVEJOB_TEMPORAL_TARGET, ACTIVEJOB_TEMPORAL_NAMESPACE, ACTIVEJOB_TEMPORAL_TASK_QUEUE_PREFIX, ACTIVEJOB_TEMPORAL_TASK_QUEUE, ACTIVEJOB_TEMPORAL_MAX_PAYLOAD_SIZE_KB, ACTIVEJOB_TEMPORAL_DEPENDENCY_WAIT_TIMEOUT_SECONDS, ACTIVEJOB_TEMPORAL_DEPENDENCY_WAIT_INITIAL_INTERVAL_SECONDS, ACTIVEJOB_TEMPORAL_DEPENDENCY_WAIT_MAX_INTERVAL_SECONDS, ACTIVEJOB_TEMPORAL_DEPENDENCY_WAIT_BACKOFF, ACTIVEJOB_TEMPORAL_MAX_CONCURRENT_ACTIVITIES, ACTIVEJOB_TEMPORAL_MAX_CONCURRENT_WORKFLOW_TASKS, can provide defaults.

Configuration object for the activejob-temporal gem.

Holds connection settings, timeouts, retry policies, and operational flags. Use configure to set values with automatic validation.

See Also:

Constant Summary collapse

REDACTED_ATTRIBUTES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Attributes holding secrets, redacted by #inspect.

%i[encryption_key encryption_old_keys tls api_key].freeze
REDACTED_PLACEHOLDER =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"[FILTERED]"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Configuration.



487
488
489
490
491
492
493
# File 'lib/activejob/temporal/configuration.rb', line 487

def initialize
  @attributes = {}
  @in_configure_block = false
  CONFIGURATION_ATTRIBUTES.each do |attribute, |
    @attributes[attribute] = resolve_default_value()
  end
end

Instance Attribute Details

#in_configure_blockObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



473
474
475
# File 'lib/activejob/temporal/configuration.rb', line 473

def in_configure_block
  @in_configure_block
end

Class Method Details

.format_validation_errors(errors) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



549
550
551
552
553
554
555
556
557
558
559
# File 'lib/activejob/temporal/configuration.rb', line 549

def self.format_validation_errors(errors)
  messages = errors.full_messages
  return messages.first if messages.size == 1

  error_list = messages.each_with_index.map do |message, index|
    "  #{index + 1}. #{message}"
  end.join("\n")

  plural = "s" if messages.size > 1
  "Configuration validation failed with #{messages.size} error#{plural}:\n#{error_list}"
end

Instance Method Details

#[](key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



503
504
505
# File 'lib/activejob/temporal/configuration.rb', line 503

def [](key)
  @attributes[key]
end

#[]=(key, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



507
508
509
# File 'lib/activejob/temporal/configuration.rb', line 507

def []=(key, value)
  @attributes[key] = value
end

#add_middleware(middleware) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



511
512
513
# File 'lib/activejob/temporal/configuration.rb', line 511

def add_middleware(middleware, ...)
  middleware_chain.add(middleware, ...)
end

#finalize_configuration_copy!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



544
545
546
547
# File 'lib/activejob/temporal/configuration.rb', line 544

def finalize_configuration_copy!
  observability.finalize_configuration_copy! if observability.respond_to?(:finalize_configuration_copy!)
  self
end

#initialize_copy(original) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



495
496
497
498
499
500
501
# File 'lib/activejob/temporal/configuration.rb', line 495

def initialize_copy(original)
  super
  @attributes = original.instance_variable_get(:@attributes).transform_values do |value|
    duplicate_configuration_value(value)
  end
  @in_configure_block = false
end

#inspectString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the configuration with secret attributes redacted.

The default Object#inspect dumps @attributes, which exposes the payload encryption keys and the inline TLS private key in logs and exception output.

Returns:

  • (String)

    inspect output with encryption keys and TLS settings filtered



525
526
527
528
529
530
531
532
533
# File 'lib/activejob/temporal/configuration.rb', line 525

def inspect
  pairs = @attributes.map do |attribute, value|
    value = REDACTED_PLACEHOLDER if REDACTED_ATTRIBUTES.include?(attribute) && value.present?

    "#{attribute}=#{value.inspect}"
  end

  "#<#{self.class.name} #{pairs.join(', ')}>"
end

#validate!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



535
536
537
538
539
540
541
542
# File 'lib/activejob/temporal/configuration.rb', line 535

def validate!
  return if validation_level == :none

  validator = build_validator
  return if validator.valid?

  handle_validation_errors(validator.errors)
end