Class: FluQ::Runner

Inherits:
Object
  • Object
show all
Includes:
Mixins::Loggable
Defined in:
lib/fluq/runner.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixins::Loggable

#logger

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

Parameters:

  • name (String)


22
23
24
# File 'lib/fluq/runner.rb', line 22

def feed(name, &block)
  @feeds.supervise FluQ::Feed, name, &block
end

#feedsArray<FluQ::Feed>

Returns:



16
17
18
# File 'lib/fluq/runner.rb', line 16

def feeds
  @feeds.actors
end

#inspectString

Returns introspection.

Returns:

  • (String)

    introspection



37
38
39
# File 'lib/fluq/runner.rb', line 37

def inspect
  "#<#{self.class.name} feeds: #{feeds.map(&:name).inspect}>"
end

#runObject

Starts the runner, blocking



27
28
29
# File 'lib/fluq/runner.rb', line 27

def run
  loop { sleep 5 while @feeds.alive? }
end

#terminateObject

Terminates the runner



32
33
34
# File 'lib/fluq/runner.rb', line 32

def terminate
  @feeds.terminate
end