Module: Robinhood

Defined in:
lib/robinhood.rb,
lib/robinhood/dsl.rb,
lib/robinhood/mutex.rb,
lib/robinhood/daemon.rb,
lib/robinhood/process.rb,
lib/robinhood/runtime.rb,
lib/robinhood/version.rb

Defined Under Namespace

Classes: DSL, Daemon, Mutex, Process, Runtime

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.define(&block) ⇒ Object

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


21
22
23
# File 'lib/robinhood.rb', line 21

def self.define(&block)
  dsl.instance_eval(&block) if block
end

.log(loglevel, message) ⇒ Object

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.



60
61
62
63
# File 'lib/robinhood.rb', line 60

def self.log(loglevel, message)
  logger.send loglevel, message if logger
  nil
end

.logger=(logger) ⇒ Object

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

Returns the Logger.



50
51
52
# File 'lib/robinhood.rb', line 50

def self.logger=(logger)
  @logger = logger
end

.reset!Object

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

Returns nil.



68
69
70
71
# File 'lib/robinhood.rb', line 68

def self.reset!
  stop
  @runtime = nil
end

.run(options = {}) ⇒ Object

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.



33
34
35
36
# File 'lib/robinhood.rb', line 33

def self.run(options = {})
  runtime.run(options)
  nil
end

.stopObject

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

Returns nil.



41
42
43
44
# File 'lib/robinhood.rb', line 41

def self.stop
  runtime.stop if runtime
  nil
end