Class: Opee::Collector

Inherits:
Actor
  • Object
show all
Defined in:
lib/opee/collector.rb

Overview

This class is used to collect multiple paths together before proceeding in a system. Two approaches are supported, either let the Collector subclass identify when it is time to move on or put the logic in the Job that is passed between the various Actors.

To use a Collector, pass the same data along each path of Actors. All paths should terminate at the Collector. From there the Collector keeps a cache of the data's key and a token that is used to track arrivals. When all paths have converged the next Actor in the process is called.

Constant Summary

Constant Summary

Constants inherited from Actor

Actor::CLOSING, Actor::RUNNING, Actor::STEP, Actor::STOPPED

Instance Attribute Summary

Attributes inherited from Actor

#name, #state

Instance Method Summary (collapse)

Methods inherited from Actor

#ask, #ask_timeout, #backed_up, #busy?, #close, #max_queue_count, #method_missing, #on_idle, #priority_ask, #proc_count, #queue_count, #start, #state_string, #step, #stop, #timeout_ask, #wakeup

Constructor Details

- (Collector) initialize(options = {})

Returns a new instance of Collector



14
15
16
17
18
19
# File 'lib/opee/collector.rb', line 14

def initialize(options={})
  @cache = {}
  @next_actor = nil
  @next_method = nil
  super(options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Opee::Actor

Instance Method Details

- (Fixnum) cache_size

Returns the number of Jobs currently waiting to be matched.

Returns:

  • (Fixnum)

    current number of Jobs waiting to finish.



23
24
25
# File 'lib/opee/collector.rb', line 23

def cache_size()
  @cache.size()
end