Class: Rstatsd::Server

Inherits:
EventMachine::Connection
  • Object
show all
Includes:
EventMachine::HttpServer, Helpers
Defined in:
lib/rstatsd/server.rb

Instance Method Summary collapse

Methods included from Helpers

#counter_key_name, #fetch_counters, #format_key, #redis, #redis_data_for, #timer_key_name

Instance Method Details

#post_initObject



14
15
16
# File 'lib/rstatsd/server.rb', line 14

def post_init
  super
end

#process_http_requestObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rstatsd/server.rb', line 18

def process_http_request
  response = EM::DelegatedHttpResponse.new(self)

  case @http_request_uri
  when '/'
    response.content_type 'text/html'
    response.content = File.open('templates/index.html').read
    response.send_response
  when '/stats'
    Rstatsd::Chart.new(@http_query_string).draw_chart do |chart|
      @chart = chart
      google_chart = ERB.new(File.open('templates/google_chart.erb').read).
        result(binding)
      response.content_type 'text/html'
      response.content = google_chart
      response.send_response
    end
  end
end