Sha256: 5fe468799c06cbc9c0dac4542d52eba05108294519e0a3a655155c19126ba392
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
require 'riemann/babbler/client' require 'resolv' require 'socket' module Riemann module Babbler class Sender class Client include Riemann::Babbler::Logging include Riemann::Babbler::Options include Riemann::Babbler::Errors INTERVAL_FLUSH = 0.1 attr_accessor :host, :port, :events def initialize(host) @host, @port = host.split(':') @port ||= opts.riemann.port @events = Array.new start end def start build_client @running = true @runner = Thread.new { while @running sleep INTERVAL_FLUSH flush end @runner = nil } end def stop @running = false end def alive? return false if @runner.nil? @runner.alive? end def <<(event) @events.shift if @events.size > opts.riemann.backlog @events << event end private # flush events def flush @riemann << @events log :debug, "Posted event (#{@host}:#{@port}): #{events.inspect}" @events.clear end # riemann client def build_client @riemann = nil @riemann = Riemann::Babbler::Client.new({ :host => Resolv.new.getaddress(@host), :port => @port }) @riemann end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
riemann-babbler-2.8.0 | lib/riemann/babbler/sender_client.rb |