Sha256: ff90c2126683750b32050066846d74b4913e3720675902e3c79ec48df42d25fd

Contents?: true

Size: 532 Bytes

Versions: 1

Compression:

Stored size: 532 Bytes

Contents

module Rtsd
  class Client
    attr_reader :connection

    def initialize(options = {})
      @connection = Rtsd::Connection.new(options)
    end

    def put(params)
      metric    = params.fetch(:metric)
      timestamp = params[:timestamp] || Time.now.to_i
      value     = params.fetch(:value).to_f
      tags      = params.fetch(:tags).map{|k,v| "#{k}=#{v}"}.join(" ")
      connection.puts "put %s %d %s %s" % [metric, timestamp, value, tags]
    rescue KeyError => e
      raise ArgumentError, e.message
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rtsd-0.0.2 lib/rtsd/client.rb