Class: FluQ::Input::Base

Inherits:
Object
  • Object
show all
Includes:
Celluloid::IO, Mixins::Loggable
Defined in:
lib/fluq/input/base.rb

Direct Known Subclasses

Noop, Socket

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixins::Loggable

#logger

Constructor Details

#initialize(source, handlers, options = {}) ⇒ Base

Returns a new instance of Base.

Parameters:

  • source (String)

    feed name

  • handlers (Array<Class,multiple>)

    handler builders

  • options (Hash) (defaults to: {})

    various configuration options



15
16
17
18
19
20
21
22
23
# File 'lib/fluq/input/base.rb', line 15

def initialize(source, handlers, options = {})
  super()
  @config = defaults.merge(options)
  configure

  @worker = FluQ::Worker.new_link [source, name].join(":"), handlers
  logger.info "#{source}: listening to #{description}"
  async.run
end

Instance Attribute Details

#configObject (readonly)



7
8
9
# File 'lib/fluq/input/base.rb', line 7

def config
  @config
end

#workerObject (readonly)



10
11
12
# File 'lib/fluq/input/base.rb', line 10

def worker
  @worker
end

Instance Method Details

#descriptionString

Returns descriptive name.

Returns:

  • (String)

    descriptive name



31
32
33
# File 'lib/fluq/input/base.rb', line 31

def description
  name
end

#nameString

Returns short name.

Returns:

  • (String)

    short name



26
27
28
# File 'lib/fluq/input/base.rb', line 26

def name
  @name ||= self.class.name.split("::")[-1].downcase
end

#process(data) ⇒ Object

Processes data

Parameters:

  • data (String)


41
42
43
# File 'lib/fluq/input/base.rb', line 41

def process(data)
  worker.process format.parse(data)
end

#runObject

Start the input



36
37
# File 'lib/fluq/input/base.rb', line 36

def run
end