Commit b5c36742 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

fixed inbound streams

parent a3ee6454
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -114,10 +114,18 @@ module FnordMetric

  def self.standalone
    puts "DEPRECATION WARNING - FIXPAUL"

    FnordMetric::Web.new(
      :host => options[:web_interface][0],
      :port => options[:web_interface][1]
    )

    FnordMetric::Acceptor.new(
      :protocol => options[:inbound_protocol],
      :host => options[:inbound_stream][0],
      :port => options[:inbound_stream][1]
    )

    start_em
  end

@@ -133,6 +141,8 @@ require "fnordmetric/gauge_rendering"
require "fnordmetric/gauge"
require "fnordmetric/context"

require "fnordmetric/api"

require "fnordmetric/web/web"
require "fnordmetric/web/app_helpers"
require "fnordmetric/web/app"
+5 −3
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ class FnordMetric::TCPAcceptor < EventMachine::Connection
  def push_next_event
    return true if @events.empty?
    @events_buffered -= 1
    @backend.publish(@events.pop)
    api.event(@events.pop)
    close_connection?
    EM.next_tick(&method(:push_next_event))
  end
@@ -40,8 +40,6 @@ class FnordMetric::TCPAcceptor < EventMachine::Connection
  end

  def post_init
    puts options.inspect
    @backend = options[:backend][0].new(options[:backend][1])
    @events_buffered = 0
    @streaming = true
    @buffer = ""
@@ -52,4 +50,8 @@ class FnordMetric::TCPAcceptor < EventMachine::Connection
    @streaming = false
    close_connection?
  end

  def api
    @api ||= FnordMetric::API.new
  end
end
+4 −3
Original line number Diff line number Diff line
@@ -7,8 +7,6 @@ class FnordMetric::UDPAcceptor < EventMachine::Connection
  def self.start(opts)
    self.opts = opts

    @backend = @opts[:backend][0].new(@opts[:backend][1])

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

@@ -20,7 +18,7 @@ class FnordMetric::UDPAcceptor < EventMachine::Connection
  def push_next_event
    return true if events.empty?
    ev = @events.pop
    backend.publish(ev)
    apu.event(ev)
    EM.next_tick(&method(:push_next_event))
  end

@@ -32,4 +30,7 @@ class FnordMetric::UDPAcceptor < EventMachine::Connection
    @events ||= []
  end

  def api
    @api ||= FnordMetric::API.new
  end
end
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
class FnordMetric::API

  @@opts = nil

  def initialize opts
  def initialize(opts={})
    @@opts = FnordMetric.default_options(opts)
    connect
  end

proto.md

deleted100644 → 0
+0 −54
Original line number Diff line number Diff line


GAUGE OVERLAY PROTOCOL

    gauge discovery:

      { "_class":"discover_request"}
      { "_class":"discover_response", "gauge_key":"gauge123" }


    render a gauge (request):

      { "_class":"render_request", "_channel":"$GAUGE_NAME" }
      { "_class":"render_response", "_channel":"$GAUGE_NAME", "payload": "$PAYLOAD" }




LOGGER

    options
       :file, :channels




ACCEPTOR

    options
       :protocol, :host, :port




TIMELINEWIDGET

    options

        :title, :tab, :ticks, :series, :series_titles, :include_current, :height
        :draw_points, draw_path, draw_ygrid, draw_xgrid


    handlers

      values_at(series, ticks, tick)


    api json:

      request: {"_class"=>"widget_request", "_channel"=>"XXX", "cmd"=>"values_at", "tick"=>86400, "ticks"=>[1336435200, ...], "widget"=>"ZZZ" }

      response: {"_class"=>"widget_response", "_channel"=>"XXX", "cmd"=>"values_at", "tick"=>86400, "values"=> { "series1": { 123: 0, 124: 0 } }, "widget"=>"ZZZ" }

     
Loading