Class: FnordMetric::UDPAcceptor
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- FnordMetric::UDPAcceptor
- Defined in:
- lib/fnordmetric/acceptors/udp_acceptor.rb
Class Attribute Summary collapse
-
.opts ⇒ Object
Returns the value of attribute opts.
Class Method Summary collapse
Instance Method Summary collapse
- #api ⇒ Object
- #events ⇒ Object
- #push_next_event ⇒ Object
- #receive_data(event) ⇒ Object
- #unbind ⇒ Object
Class Attribute Details
.opts ⇒ Object
Returns the value of attribute opts.
4 5 6 |
# File 'lib/fnordmetric/acceptors/udp_acceptor.rb', line 4 def opts @opts end |
Class Method Details
.start(opts) ⇒ Object
7 8 9 10 11 |
# File 'lib/fnordmetric/acceptors/udp_acceptor.rb', line 7 def self.start(opts) self.opts = opts EM.open_datagram_socket(*(opts[:listen] << self << opts)) end |
Instance Method Details
#api ⇒ Object
33 34 35 |
# File 'lib/fnordmetric/acceptors/udp_acceptor.rb', line 33 def api @api ||= FnordMetric::API.new(FnordMetric.) end |
#events ⇒ Object
29 30 31 |
# File 'lib/fnordmetric/acceptors/udp_acceptor.rb', line 29 def events @events ||= [] end |
#push_next_event ⇒ Object
18 19 20 21 22 23 |
# File 'lib/fnordmetric/acceptors/udp_acceptor.rb', line 18 def push_next_event return true if events.empty? ev = @events.pop api.event(ev) EM.next_tick(&method(:push_next_event)) end |
#receive_data(event) ⇒ Object
13 14 15 16 |
# File 'lib/fnordmetric/acceptors/udp_acceptor.rb', line 13 def receive_data(event) events << event push_next_event end |
#unbind ⇒ Object
25 26 27 |
# File 'lib/fnordmetric/acceptors/udp_acceptor.rb', line 25 def unbind #backend.hangup end |