Module: FFWD::Processor

Includes:
Lifecycle, Logging
Defined in:
lib/ffwd/processor.rb

Defined Under Namespace

Modules: ClassMethods Classes: Setup

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

#log

Methods included from Lifecycle

#depend_on, #start, #started?, #starting, #starting_hooks, #stop, #stopped?, #stopping, #stopping_hooks

Class Method Details

.categoryObject



81
82
83
# File 'lib/ffwd/processor.rb', line 81

def self.category
  'processor'
end

.included(mod) ⇒ Object



85
86
87
# File 'lib/ffwd/processor.rb', line 85

def self.included(mod)
  mod.extend ClassMethods
end

.load_discovered(source) ⇒ Object



89
90
# File 'lib/ffwd/processor.rb', line 89

def self.load_discovered source
end

.load_processors(config) ⇒ Object

setup hash of processor setup classes.



93
94
95
96
97
98
99
100
101
102
# File 'lib/ffwd/processor.rb', line 93

def self.load_processors config
  registry.map do |name, klass|
    unless klass.respond_to? :prepare
      raise "Processor #{klass} does not have a 'prepare' method"
    end

    config = klass.prepare Hash[config[name] || {}]
    Setup.new name, klass, config
  end
end

.registryObject



77
78
79
# File 'lib/ffwd/processor.rb', line 77

def self.registry
  @@registry ||= {}
end

Instance Method Details

#nameObject



73
74
75
# File 'lib/ffwd/processor.rb', line 73

def name
  self.class.name
end

#process(m) ⇒ Object

Module to include for processors.

Usage:

class MyProcessor

include FFWD::Processor

register_processor "my_processor"

def initialize opts
  .. read options ..
end

def start emitter
  ... setup EventMachine tasks ...
end

def process emitter, m
  ... process a single metric ...
  emitter.metrics.emit ...
end

end

Raises:

  • (Exception)


59
60
61
# File 'lib/ffwd/processor.rb', line 59

def process m
  raise Exception.new("process: Not Implemented")
end