module FnordMetric
Constants
- COLORS
- DEFAULT_OPTIONS
- DEFAULT_PROC
- TICKS
- VERSION
Public Class Methods
default_options(opts = {})
click to toggle source
# File lib/fnordmetric.rb, line 53 def self.default_options(opts = {}) FnordMetric::DEFAULT_OPTIONS.merge(opts) end
error(msg)
click to toggle source
# File lib/fnordmetric.rb, line 61 def self.error(msg) log "[ERROR] #{msg}"; nil end
error!(msg)
click to toggle source
# File lib/fnordmetric.rb, line 65 def self.error!(msg) raise msg if ENV['FNORDMETRIC_ENV'] == 'test' puts(msg); exit! end
log(msg)
click to toggle source
# File lib/fnordmetric.rb, line 57 def self.log(msg) puts "[#{Time.now.strftime("%y-%m-%d %H:%M:%S")}] #{msg}" end
mk_redis()
click to toggle source
# File lib/fnordmetric.rb, line 49 def self.mk_redis Redis.new(:url => options[:redis_url]) end
namespace(key=nil, &block)
click to toggle source
# File lib/fnordmetric.rb, line 23 def self.namespace(key=nil, &block) @@namespaces[key] = block end
namespaces()
click to toggle source
# File lib/fnordmetric.rb, line 27 def self.namespaces {}.tap do |_namespaces| @@namespaces.each do |key, block| _namespaces[key] = FnordMetric::Namespace.new(key, options.clone) _namespaces[key].instance_eval(&block) _namespaces[key].instance_eval(&FnordMetric::DEFAULT_PROC) end end end
options(opts = {})
click to toggle source
# File lib/fnordmetric.rb, line 37 def self.options(opts = {}) default_options(@@options || {}).merge(opts) end
options=(opts)
click to toggle source
# File lib/fnordmetric.rb, line 41 def self.options=(opts) @@options = opts end
register(obj)
click to toggle source
# File lib/fnordmetric.rb, line 45 def self.register(obj) @@pool.push(obj) end
run()
click to toggle source
# File lib/fnordmetric.rb, line 70 def self.run start_em rescue Exception => e raise e log "!!! eventmachine died, restarting... #{e.message}" sleep(1); run end
server_configuration=(configuration)
click to toggle source
# File lib/fnordmetric.rb, line 96 def self.server_configuration=(configuration) puts "DEPRECATION WARNING - FIXPAUL" self.options=(configuration) end
shutdown(fnord=nil)
click to toggle source
# File lib/fnordmetric.rb, line 78 def self.shutdown(fnord=nil) log "shutting down, byebye" EM.stop end
standalone()
click to toggle source
# File lib/fnordmetric.rb, line 101 def self.standalone puts "DEPRECATION WARNING - FIXPAUL" require "fnordmetric/standalone" start_em end
start_em()
click to toggle source
# File lib/fnordmetric.rb, line 83 def self.start_em EM.run do trap("TERM", &method(:shutdown)) trap("INT", &method(:shutdown)) EM.next_tick do (@@pool || []).map(&:initialized) end end end