module Robinhood

Constants

VERSION

Public Class Methods

define(&block) click to toggle source

Public: The starting point for Robinhood’s DSL.

Example:

Robinhood.define do
  redis{ Redis.new(host: 'foobar') }

  process :ed, timeout: 100 do
    Balls.process!
  end

  process :sweeper, throttle: 5 do
    Sweeper.sweep!
  end
end
# File lib/robinhood.rb, line 21
def self.define(&block)
  dsl.instance_eval(&block) if block
end
log(loglevel, message) click to toggle source

Private: Logs messages to the logger.

loglevel - The message’s log level: :info, :error or :debug message - A String with the message to be logged

Returns nil.

# File lib/robinhood.rb, line 60
def self.log(loglevel, message)
  logger.send loglevel, message if logger
  nil
end
logger=(logger) click to toggle source

Public: Assigns a Logger to Robinhood where it will output info, debug and error messages.

Returns the Logger.

# File lib/robinhood.rb, line 50
def self.logger=(logger)
  @logger = logger
end
reset!() click to toggle source

Semi-public: Resets robinhood to a clean state. Mostly used on testing.

Returns nil.

# File lib/robinhood.rb, line 68
def self.reset!
  stop
  @runtime = nil
end
run(options = {}) click to toggle source

Public: Runs a previously configured Robinhood instance.

options - A hash of options to configure the execution.

(default: {background: false})
:background - True if it has to be run on the background (doesn't
              block the main thread), False otherwise.

Returns nil.

# File lib/robinhood.rb, line 33
def self.run(options = {})
  runtime.run(options)
  nil
end
stop() click to toggle source

Public: Stops Robinhood’s execution, if it was run on the background.

Returns nil.

# File lib/robinhood.rb, line 41
def self.stop
  runtime.stop if runtime
  nil
end

Private Class Methods

dsl() click to toggle source
# File lib/robinhood.rb, line 84
def self.dsl
  @dsl ||= DSL.new(runtime)
end
logger() click to toggle source
# File lib/robinhood.rb, line 73
def self.logger
  return @logger if defined?(@logger)
  @logger = Logger.new(STDOUT)
end
runtime() click to toggle source
# File lib/robinhood.rb, line 79
def self.runtime
  @runtime ||= Runtime.new
end