Class: RFlow::Shard
- Inherits:
-
Object
- Object
- RFlow::Shard
- Defined in:
- lib/rflow/shard.rb
Overview
An object implementation shared between two processes. The parent process will instantiate, configure, and run! a Shard, at which point the parent will have access to the Shard object and be able to monitor the underlying Worker processes. The child implementation, running in a separate process, will not return from spawn!
, but start an EventMachine reactor.
Defined Under Namespace
Classes: Worker
Instance Attribute Summary collapse
-
#config ⇒ Configuration::Shard
readonly
Reference to the Shard‘s configuration.
-
#count ⇒ Integer
readonly
The count of workers that should be started.
-
#name ⇒ String
readonly
The Shard‘s name.
-
#workers ⇒ Array<Worker>
readonly
Reference to the actual Workers.
Instance Method Summary collapse
-
#initialize(config) ⇒ Shard
constructor
A new instance of Shard.
-
#run! ⇒ void
Start the shard by spawning and starting all the workers.
Constructor Details
Instance Attribute Details
#config ⇒ Configuration::Shard (readonly)
Reference to the RFlow::Shard‘s configuration.
99 100 101 |
# File 'lib/rflow/shard.rb', line 99 def config @config end |
#count ⇒ Integer (readonly)
The count of workers that should be started.
107 108 109 |
# File 'lib/rflow/shard.rb', line 107 def count @count end |
#name ⇒ String (readonly)
The RFlow::Shard‘s name.
103 104 105 |
# File 'lib/rflow/shard.rb', line 103 def name @name end |
Instance Method Details
#run! ⇒ void
This method returns an undefined value.
Start the shard by spawning and starting all the workers.
123 124 125 126 127 128 129 |
# File 'lib/rflow/shard.rb', line 123 def run! RFlow.logger.debug "Running shard #{name} with #{count} workers" workers.each(&:spawn!) RFlow.logger.debug "#{count} workers started for #{name}: #{workers.map { |w| "#{w.name} (#{w.pid})" }.join(', ')}" workers end |