Module: ActiveJob::Temporal::DependencyOptions
- Defined in:
- lib/activejob/temporal/dependency_options.rb
Constant Summary collapse
- JOB_CLASS_NAME_PATTERN =
/\A[A-Z]\w*(?:::[A-Z]\w*)*\z/- SAFE_ID_PATTERN =
/\A[A-Za-z0-9_.:-]+\z/- FAILURE_POLICIES =
%i[fail ignore].freeze
- WAIT_OPTION_KEYS =
%i[timeout initial_interval max_interval backoff].freeze
Instance Attribute Summary collapse
-
#temporal_dependencies ⇒ Object
readonly
Returns the value of attribute temporal_dependencies.
-
#temporal_dependency_failure_policy ⇒ Object
readonly
Returns the value of attribute temporal_dependency_failure_policy.
-
#temporal_dependency_wait ⇒ Object
readonly
Returns the value of attribute temporal_dependency_wait.
Class Method Summary collapse
- .normalize(depends_on) ⇒ Object
- .normalize_failure_policy(policy) ⇒ Object
- .normalize_wait_options(options) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#temporal_dependencies ⇒ Object (readonly)
Returns the value of attribute temporal_dependencies.
14 15 16 |
# File 'lib/activejob/temporal/dependency_options.rb', line 14 def temporal_dependencies @temporal_dependencies end |
#temporal_dependency_failure_policy ⇒ Object (readonly)
Returns the value of attribute temporal_dependency_failure_policy.
14 15 16 |
# File 'lib/activejob/temporal/dependency_options.rb', line 14 def temporal_dependency_failure_policy @temporal_dependency_failure_policy end |
#temporal_dependency_wait ⇒ Object (readonly)
Returns the value of attribute temporal_dependency_wait.
14 15 16 |
# File 'lib/activejob/temporal/dependency_options.rb', line 14 def temporal_dependency_wait @temporal_dependency_wait end |
Class Method Details
.normalize(depends_on) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/activejob/temporal/dependency_options.rb', line 16 def self.normalize(depends_on) dependencies = depends_on.is_a?(Array) ? depends_on : [depends_on] raise ArgumentError, "depends_on must contain at least one job dependency" if dependencies.empty? dependencies.map { |dependency| normalize_dependency(dependency) } end |
.normalize_failure_policy(policy) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/activejob/temporal/dependency_options.rb', line 23 def self.normalize_failure_policy(policy) normalized_policy = policy.to_sym return normalized_policy if FAILURE_POLICIES.include?(normalized_policy) raise ArgumentError, "on_dependency_failure must be :fail or :ignore" rescue NoMethodError raise ArgumentError, "on_dependency_failure must be :fail or :ignore" end |
.normalize_wait_options(options) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/activejob/temporal/dependency_options.rb', line 32 def self.() raise ArgumentError, "dependency_wait must be a hash" unless .is_a?(Hash) normalized = .each_with_object({}) do |(key, value), | normalized_key = normalize_wait_option_key(key) [normalized_key] = normalize_wait_option_value(normalized_key, value) end validate_wait_interval_order!(normalized) normalized end |
Instance Method Details
#set(options = {}) ⇒ Object
163 164 165 166 167 168 169 170 171 |
# File 'lib/activejob/temporal/dependency_options.rb', line 163 def set( = {}) = .dup = () () super().tap do () end end |