class RFlow::Shard
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 {Shard::Worker} processes. The child implementation, running in a separate process, will not return from spawn!
, but start an EventMachine reactor.
Attributes
config[R]
Reference to the {Shard}'s configuration. @return [Configuration::Shard]
count[R]
The count of workers that should be started. @return [Integer]
name[R]
The {Shard}'s name. @return [String]
workers[R]
Reference to the actual {Worker}s. @return [Array<Worker>]
Public Class Methods
new(config)
click to toggle source
# File lib/rflow/shard.rb, line 113 def initialize(config) @config = config @uuid = config.uuid @name = config.name @count = config.count @workers = count.times.map {|i| Worker.new(self, i+1) } end
Public Instance Methods
run!()
click to toggle source
Start the shard by spawning and starting all the workers. @return [void]
# 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