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

build_meta, 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.



41
42
43
44
45
46
# File 'lib/ffwd/plugin_channel.rb', line 41

def initialize id, events, metrics
  @id = id
  @events = events
  @metrics = metrics
  @reporter_meta = {:channel => @id}
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



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

def events
  @events
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#metricsObject (readonly)

Returns the value of attribute metrics.



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

def metrics
  @metrics
end

#reporter_metaObject (readonly)

Returns the value of attribute reporter_meta.



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

def reporter_meta
  @reporter_meta
end

Class Method Details

.build(id) ⇒ Object



35
36
37
38
39
# File 'lib/ffwd/plugin_channel.rb', line 35

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



52
53
54
55
# File 'lib/ffwd/plugin_channel.rb', line 52

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

#event_subscribe(&block) ⇒ Object



48
49
50
# File 'lib/ffwd/plugin_channel.rb', line 48

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

#metric(metric) ⇒ Object



61
62
63
64
# File 'lib/ffwd/plugin_channel.rb', line 61

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

#metric_subscribe(&block) ⇒ Object



57
58
59
# File 'lib/ffwd/plugin_channel.rb', line 57

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