Class: Robinhood::Process

Inherits:
Object
  • Object
show all
Includes:
Celluloid, Celluloid::Logger
Defined in:
lib/robinhood/process.rb

Overview

This class wraps a previously defined process. It’s responsible to prevent the same process to be run at the sime time on different System Processes.

A Process leverages a Celluloid Actor, so it will spawned in a different thread and communicate with the rest of the system with messages.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options, block) ⇒ Process

Public: Initializes a Process

name - A String that will be used as a global identifier. It’s

important that it is unique, since the locking will be
performed this name as scope.

options - A Hash of options that configure this Process.

:throttle - An Integer that represents the minimum number of
            seconds that this process will take. In other
            words, if its execution takes less than that, we'll
            wait a little bit until it hits the next execution.
:timeout  - An Integer representing the period of time after
            which this process' execution will be considered as
            'hung' and another execution will take place.

block - The block that will be evaluated each time this Process gets

executed.


34
35
36
37
38
39
# File 'lib/robinhood/process.rb', line 34

def initialize(name, options, block)
  @name = name
  @options = options
  @block = block
  async.run
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end