Sha256: a8d8fff639ce9f314cc01905592d3533a9f49d0f55676daf85df8756fba14a6b

Contents?: true

Size: 591 Bytes

Versions: 3

Compression:

Stored size: 591 Bytes

Contents

class FnordMetric::UDPAcceptor < EventMachine::Connection

  class << self
    attr_accessor :opts
  end

  def self.start(opts)
    self.opts = opts

    EM.open_datagram_socket(*(opts[:listen] << self << opts))
  end

  def receive_data(event)
    events << event
    push_next_event
  end

  def push_next_event
    return true if events.empty?
    ev = @events.pop
    api.event(ev)
    EM.next_tick(&method(:push_next_event))
  end

  def unbind
    #backend.hangup
  end

  def events
    @events ||= []
  end

  def api
    @api ||= FnordMetric::API.new(FnordMetric.options)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fnordmetric-1.0.1 lib/fnordmetric/acceptors/udp_acceptor.rb
fnordmetric-1.0.0 lib/fnordmetric/acceptors/udp_acceptor.rb
fnordmetric-0.9.7 lib/fnordmetric/acceptors/udp_acceptor.rb