class FFWD::Plugin::Protobuf::InputUDP

Public Class Methods

new(bind, core, config) click to toggle source
# File lib/ffwd/plugin/protobuf.rb, line 67
def initialize bind, core, config
  @bind = bind
  @core = core
end
plugin_type() click to toggle source
# File lib/ffwd/plugin/protobuf.rb, line 72
def self.plugin_type
  "protobuf"
end

Public Instance Methods

receive_data(datagram) click to toggle source
# File lib/ffwd/plugin/protobuf.rb, line 76
def receive_data datagram
  Serializer.load(datagram) do |type, data|
    if type == :event
      @core.input.event data
      @bind.increment :received_events
      next
    end

    if type == :metric
      @core.input.metric data
      @bind.increment :received_metrics
      next
    end
  end
rescue => e
  log.error "Failed to receive data", e

  if log.debug?
    log.debug("DUMP: " + FFWD.dump2hex(datagram))
  end
end