Class: FnordMetric::Acceptor
- Inherits:
-
Object
- Object
- FnordMetric::Acceptor
- Defined in:
- lib/fnordmetric/acceptors/acceptor.rb
Instance Method Summary collapse
-
#initialize(opts) ⇒ Acceptor
constructor
A new instance of Acceptor.
- #initialized ⇒ Object
Constructor Details
#initialize(opts) ⇒ Acceptor
Returns a new instance of Acceptor.
3 4 5 6 7 |
# File 'lib/fnordmetric/acceptors/acceptor.rb', line 3 def initialize(opts) @opts = opts FnordMetric.register(self) end |
Instance Method Details
#initialized ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/fnordmetric/acceptors/acceptor.rb', line 9 def initialized inbound_class = if @opts[:protocol] == :udp FnordMetric::UDPAcceptor elsif @opts[:protocol] == :tcp FnordMetric::TCPAcceptor elsif @opts[:protocol] == :fyrehose FnordMetric::FyrehoseAcceptor elsif @opts[:protocol] == :amqp FnordMetric::AMQPAcceptor elsif @opts[:protocol] == :stomp FnordMetric::STOMPAcceptor else raise "unknown protocol: #{@opts[:protocol]}" end @opts[:listen] = [ @opts[:host] || "0.0.0.0", @opts[:port] || 2323 ] begin inbound_stream = inbound_class.start(@opts) if inbound_class.respond_to?(:outbound?) && inbound_class.outbound? FnordMetric.log "connected to #{@opts[:protocol]}://#{@opts[:listen][0..1].join(":")}" else FnordMetric.log "listening on #{@opts[:protocol]}://#{@opts[:listen][0..1].join(":")}" end rescue Exception => e raise e if ENV["FNORDMETRIC_ENV"] == "dev" FnordMetric.log "cant start #{inbound_class.name} on #{@opts[:protocol]}://#{@opts[:listen][0..1].join(":")}. port in use?" end end |