Class: StatsdServer::Input::Udp

Inherits:
EventMachine::Connection
  • Object
show all
Defined in:
lib/statsdserver/input/udp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeUdp

Returns a new instance of Udp.



12
13
14
# File 'lib/statsdserver/input/udp.rb', line 12

def initialize
  @logger = Logger.new(STDOUT)
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



8
9
10
# File 'lib/statsdserver/input/udp.rb', line 8

def logger
  @logger
end

#statsObject

Returns the value of attribute stats.



8
9
10
# File 'lib/statsdserver/input/udp.rb', line 8

def stats
  @stats
end

Instance Method Details

#receive_data(packet) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/statsdserver/input/udp.rb', line 17

def receive_data(packet)
  raise "@stats must be set" unless @stats

  begin
    StatsdServer::Proto::V1.parse(packet, @stats)
  rescue StatsdServer::Proto::ParseError => e
    @logger.warn(e.message)
  end
end