Module: CMDx

Extended by:
CMDx
Included in:
CMDx
Defined in:
lib/cmdx.rb,
lib/cmdx/task.rb,
lib/cmdx/util.rb,
lib/cmdx/chain.rb,
lib/cmdx/fault.rb,
lib/cmdx/input.rb,
lib/cmdx/retry.rb,
lib/cmdx/errors.rb,
lib/cmdx/inputs.rb,
lib/cmdx/output.rb,
lib/cmdx/result.rb,
lib/cmdx/signal.rb,
lib/cmdx/context.rb,
lib/cmdx/mergers.rb,
lib/cmdx/outputs.rb,
lib/cmdx/railtie.rb,
lib/cmdx/runtime.rb,
lib/cmdx/version.rb,
lib/cmdx/pipeline.rb,
lib/cmdx/retriers.rb,
lib/cmdx/settings.rb,
lib/cmdx/workflow.rb,
lib/cmdx/callbacks.rb,
lib/cmdx/coercions.rb,
lib/cmdx/executors.rb,
lib/cmdx/telemetry.rb,
lib/cmdx/i18n_proxy.rb,
lib/cmdx/validators.rb,
lib/cmdx/deprecation.rb,
lib/cmdx/deprecators.rb,
lib/cmdx/middlewares.rb,
lib/cmdx/logger_proxy.rb,
lib/cmdx/configuration.rb,
lib/cmdx/coercions/date.rb,
lib/cmdx/coercions/hash.rb,
lib/cmdx/coercions/time.rb,
lib/cmdx/coercions/array.rb,
lib/cmdx/coercions/float.rb,
lib/cmdx/deprecators/log.rb,
lib/cmdx/executors/fiber.rb,
lib/cmdx/retriers/linear.rb,
lib/cmdx/coercions/coerce.rb,
lib/cmdx/coercions/string.rb,
lib/cmdx/coercions/symbol.rb,
lib/cmdx/deprecators/warn.rb,
lib/cmdx/executors/thread.rb,
lib/cmdx/mergers/no_merge.rb,
lib/cmdx/coercions/boolean.rb,
lib/cmdx/coercions/complex.rb,
lib/cmdx/coercions/integer.rb,
lib/cmdx/deprecators/error.rb,
lib/cmdx/validators/format.rb,
lib/cmdx/validators/length.rb,
lib/cmdx/coercions/rational.rb,
lib/cmdx/log_formatters/raw.rb,
lib/cmdx/mergers/deep_merge.rb,
lib/cmdx/retriers/fibonacci.rb,
lib/cmdx/validators/absence.rb,
lib/cmdx/validators/numeric.rb,
lib/cmdx/coercions/date_time.rb,
lib/cmdx/log_formatters/json.rb,
lib/cmdx/log_formatters/line.rb,
lib/cmdx/validators/presence.rb,
lib/cmdx/validators/validate.rb,
lib/cmdx/retriers/exponential.rb,
lib/cmdx/retriers/full_random.rb,
lib/cmdx/retriers/half_random.rb,
lib/cmdx/validators/exclusion.rb,
lib/cmdx/validators/inclusion.rb,
lib/cmdx/coercions/big_decimal.rb,
lib/cmdx/log_formatters/logstash.rb,
lib/cmdx/mergers/last_write_wins.rb,
lib/cmdx/retriers/bounded_random.rb,
lib/cmdx/log_formatters/key_value.rb,
lib/cmdx/retriers/decorrelated_jitter.rb

Defined Under Namespace

Modules: LogFormatters, LoggerProxy, Util, Workflow Classes: Callbacks, Chain, Coercions, Configuration, Context, Deprecation, Deprecators, Errors, Executors, Fault, I18nProxy, Input, Inputs, Mergers, Middlewares, Output, Outputs, Pipeline, Railtie, Result, Retriers, Retry, Runtime, Settings, Signal, Task, Telemetry, Validators

Constant Summary collapse

Error =

Root exception type for the library. Every CMDx-raised exception inherits from this class, so ‘rescue CMDx::Error` (or its alias `CMDx::Exception`) catches anything thrown by the framework without trapping unrelated `StandardError` descendants. Fault is the notable subclass propagated by `execute!`.

Exception = Class.new(StandardError)
CallbackError =

Raised when an ‘around_execution` callback fails to invoke its continuation, which would otherwise silently skip the task body.

Class.new(Error)
DefinitionError =

Raised when a task or workflow attempts to define an input where an accessor with the same name already exists.

Class.new(Error)
DeprecationError =

Raised by Deprecation when a task configured with ‘deprecation(:error)` is executed. Signals that the caller must migrate off the deprecated task before continuing.

Class.new(Error)
ImplementationError =

Raised when a subclass fails to fulfill an abstract contract — most commonly when Task is invoked without overriding ‘#work`, or when a Workflow attempts to define `#work` itself.

Class.new(Error)
MiddlewareError =

Raised by the middleware chain when a registered middleware fails to yield to ‘next_link`, which would otherwise silently skip the task body.

Class.new(Error)
VERSION =

Gem version. Bumped on release; mirrored in the gemspec.

"2.0.0"

Instance Method Summary collapse

Instance Method Details

#configurationConfiguration

Returns the lazily-initialized global configuration.

Returns:

  • (Configuration)

    the lazily-initialized global configuration



49
50
51
52
53
# File 'lib/cmdx/configuration.rb', line 49

def configuration
  return @configuration if @configuration

  @configuration ||= Configuration.new
end

#configure {|Configuration| ... } ⇒ Configuration

Yields the global configuration for mutation.

Yields:

Returns:

Raises:

  • (ArgumentError)

    when no block is given



60
61
62
63
64
65
66
# File 'lib/cmdx/configuration.rb', line 60

def configure
  raise ArgumentError, "block required" unless block_given?

  config = configuration
  yield(config)
  config
end

#reset_configuration!void

This method returns an undefined value.

Replaces the global configuration with a fresh instance and invalidates the cached registries on ‘Task` so new lookups rebuild from the new config. Intended for test setup/teardown.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/cmdx/configuration.rb', line 73

def reset_configuration!
  @configuration = Configuration.new
  return unless defined?(Task)

  Task.instance_variable_set(:@middlewares, nil)
  Task.instance_variable_set(:@callbacks, nil)
  Task.instance_variable_set(:@coercions, nil)
  Task.instance_variable_set(:@validators, nil)
  Task.instance_variable_set(:@executors, nil)
  Task.instance_variable_set(:@mergers, nil)
  Task.instance_variable_set(:@retriers, nil)
  Task.instance_variable_set(:@deprecators, nil)
  Task.instance_variable_set(:@telemetry, nil)
end