Sha256: a3832711e6bc9618afba3438cac0e04c1201ec104657d707180baeb4df41a9d8

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents

class FnordMetric::Acceptor

  def initialize(opts)
    @opts = opts

    FnordMetric.register(self)
  end

  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

end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
johnf-fnordmetric-1.2.10 lib/fnordmetric/acceptors/acceptor.rb
fnordmetric-1.2.9 lib/fnordmetric/acceptors/acceptor.rb
johnf-fnordmetric-1.2.7 lib/fnordmetric/acceptors/acceptor.rb
bp-fnordmetric-1.2.7 lib/fnordmetric/acceptors/acceptor.rb
fnordmetric-1.2.7 lib/fnordmetric/acceptors/acceptor.rb
fnordmetric-1.2.6 lib/fnordmetric/acceptors/acceptor.rb
fnordmetric-1.2.4 lib/fnordmetric/acceptors/acceptor.rb
fnordmetric-1.2.1 lib/fnordmetric/acceptors/acceptor.rb
fnordmetric-1.2.0 lib/fnordmetric/acceptors/acceptor.rb