Class: FluQ::Runner
- Inherits:
-
Object
- Object
- FluQ::Runner
- Includes:
- Mixins::Loggable
- Defined in:
- lib/fluq/runner.rb
Class Method Summary collapse
-
.run(&block) ⇒ Object
Runs the runner (blocking).
Instance Method Summary collapse
-
#feed(name, &block) ⇒ Object
Registers a new feed.
- #feeds ⇒ Array<FluQ::Feed>
-
#initialize(&block) ⇒ Runner
constructor
Constructor.
-
#inspect ⇒ String
Introspection.
-
#run ⇒ Object
Starts the runner, blocking.
-
#terminate ⇒ Object
Terminates the runner.
Methods included from Mixins::Loggable
Constructor Details
#initialize(&block) ⇒ Runner
Constructor
10 11 12 13 |
# File 'lib/fluq/runner.rb', line 10 def initialize(&block) @feeds = Celluloid::SupervisionGroup.new block.call(self) if block end |
Class Method Details
.run(&block) ⇒ Object
Runs the runner (blocking)
5 6 7 |
# File 'lib/fluq/runner.rb', line 5 def self.run(&block) new(&block).run end |
Instance Method Details
#feed(name, &block) ⇒ Object
Registers a new feed
22 23 24 |
# File 'lib/fluq/runner.rb', line 22 def feed(name, &block) @feeds.supervise FluQ::Feed, name, &block end |
#feeds ⇒ Array<FluQ::Feed>
16 17 18 |
# File 'lib/fluq/runner.rb', line 16 def feeds @feeds.actors end |
#inspect ⇒ String
Returns introspection.
37 38 39 |
# File 'lib/fluq/runner.rb', line 37 def inspect "#<#{self.class.name} feeds: #{feeds.map(&:name).inspect}>" end |
#run ⇒ Object
Starts the runner, blocking
27 28 29 |
# File 'lib/fluq/runner.rb', line 27 def run loop { sleep 5 while @feeds.alive? } end |
#terminate ⇒ Object
Terminates the runner
32 33 34 |
# File 'lib/fluq/runner.rb', line 32 def terminate @feeds.terminate end |