Class: FFWD::PluginChannel

Inherits:
Object
  • Object
show all
Includes:
Lifecycle, Logging, Reporter
Defined in:
lib/ffwd/plugin_channel.rb

Overview

A set of channels, one for metrics and one for events. This is simply a convenience class to group the channel that are available to a plugin in one direction (usually either input or output).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

included, #log

Methods included from Reporter

included, #increment, map_meta, #report!, #reporter_data

Methods included from Lifecycle

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

Constructor Details

#initialize(id, events, metrics) ⇒ PluginChannel

Returns a new instance of PluginChannel.



39
40
41
42
43
44
# File 'lib/ffwd/plugin_channel.rb', line 39

def initialize id, events, metrics
  @id = id
  @events = events
  @metrics = metrics
  @reporter_meta = {:plugin_channel => @id, :type => "plugin_channel"}
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



31
32
33
# File 'lib/ffwd/plugin_channel.rb', line 31

def events
  @events
end

#idObject (readonly)

Returns the value of attribute id.



31
32
33
# File 'lib/ffwd/plugin_channel.rb', line 31

def id
  @id
end

#metricsObject (readonly)

Returns the value of attribute metrics.



31
32
33
# File 'lib/ffwd/plugin_channel.rb', line 31

def metrics
  @metrics
end

#reporter_metaObject (readonly)

Returns the value of attribute reporter_meta.



31
32
33
# File 'lib/ffwd/plugin_channel.rb', line 31

def reporter_meta
  @reporter_meta
end

Class Method Details

.build(id) ⇒ Object



33
34
35
36
37
# File 'lib/ffwd/plugin_channel.rb', line 33

def self.build id
  events = FFWD::Channel.new log, "#{id}.events"
  metrics = FFWD::Channel.new log, "#{id}.metrics"
  new id, metrics, events
end

Instance Method Details

#event(event) ⇒ Object



50
51
52
53
# File 'lib/ffwd/plugin_channel.rb', line 50

def event event
  @events << event
  increment :events
end

#event_subscribe(&block) ⇒ Object



46
47
48
# File 'lib/ffwd/plugin_channel.rb', line 46

def event_subscribe &block
  @events.subscribe(&block)
end

#metric(metric) ⇒ Object



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

def metric metric
  @metrics << metric
  increment :metrics
end

#metric_subscribe(&block) ⇒ Object



55
56
57
# File 'lib/ffwd/plugin_channel.rb', line 55

def metric_subscribe &block
  @metrics.subscribe(&block)
end