Module: Gracefully

Defined in:
lib/gracefully.rb,
lib/gracefully/try.rb,
lib/gracefully/error.rb,
lib/gracefully/health.rb,
lib/gracefully/command.rb,
lib/gracefully/counter.rb,
lib/gracefully/version.rb,
lib/gracefully/degradable.rb,
lib/gracefully/timed_command.rb,
lib/gracefully/circuit_breaker.rb,
lib/gracefully/retried_command.rb,
lib/gracefully/togglable_command.rb,
lib/gracefully/degradable_command.rb,
lib/gracefully/feature_repository.rb,
lib/gracefully/command_disabled_error.rb,
lib/gracefully/short_circuited_command.rb,
lib/gracefully/degradable_command_builder.rb,
lib/gracefully/mutex_based_synchronized_counter.rb,
lib/gracefully/consecutive_failures_based_health.rb

Defined Under Namespace

Modules: Degradable, NestedError Classes: CircuitBreaker, Command, CommandDisabledError, ConsecutiveFailuresBasedHealth, Counter, DegradableCommand, DegradableCommandBuilder, Error, Failure, FeatureRepository, Health, InMemoryCounter, MutexBasedSynchronizedCounter, RetriedCommand, ShortCircuitedCommand, SingletonInMemoryCounter, Success, TimedCommand, TogglableCommand, Try, Unresolved

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.command(*args, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gracefully.rb', line 11

def self.command(*args, &block)
  callable, options = Command.normalize_arguments(*args, &block)

  options ||= {}

  if options[:timeout]
    command(TimedCommand.new(callable, options), options.dup.tap { |h| h.delete(:timeout) })
  elsif options[:retries]
    command(RetriedCommand.new(callable, options), options.dup.tap { |h| h.delete(:retries) })
  elsif options[:allowed_failures]
    command(ShortCircuitedCommand.new(callable, options), options.dup.tap { |h| h.delete(:allowed_failures) })
  elsif options[:run_only_if]
    TogglableCommand.new(callable, options)
  else
    Command.new(callable, options)
  end
end

.degradable_command(*args, &block) ⇒ Object



7
8
9
# File 'lib/gracefully.rb', line 7

def self.degradable_command(*args, &block)
  DegradableCommandBuilder.new.usually(*args, &block)
end