Class: Robinhood::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/robinhood/dsl.rb

Overview

The DSL provides syntax suger on top of Robinhood’s runtime. It allows us to define processes in a natural language for the programmer’s convenience.

Instance Method Summary collapse

Constructor Details

#initialize(runtime) ⇒ DSL

Public: Initializes the DSL.

runtime - A runtime that will be configured using the DSL.



12
13
14
# File 'lib/robinhood/dsl.rb', line 12

def initialize(runtime)
  @runtime = runtime
end

Instance Method Details

#process(name, options = {}, &block) ⇒ Object

Public: Adds a process to the runtime.

name - The name of the process to be run. Will be used to identify the

mutex name across System Processes.

options - A set of options that will be passed to the Process. block - A block that will be called each execution of this process.

Returns nil.



24
25
26
27
# File 'lib/robinhood/dsl.rb', line 24

def process(name, options = {}, &block)
  @runtime.add_process(name, options, block)
  nil
end

#redisObject

Public: Allows a redis instance to be used to provide the locking.

Example:

Robinhood.define do

redis{ Redis.new(host: 'foo') }

end

block - A mandatory block whose result will be assigned to the runtime’s

redis client.

Returns nil.



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

def redis
  @runtime.redis = yield
  nil
end