Sha256: fb57de78f24b66ae674d8a41c60c968cb287e34b6063c0327ccd7830ced2f3e6
Contents?: true
Size: 785 Bytes
Versions: 2
Compression:
Stored size: 785 Bytes
Contents
require 'consul/async/utilities' module Consul module Async class EndPointStats attr_reader :successes, :errors, :start, :body_bytes def initialize @start = Time.now.utc @successes = 0 @errors = 0 @body_bytes = 0 end def on_response(res) @successes += 1 @body_bytes = body_bytes + res.http.response.bytesize end def on_error(_http) @errors += 1 end def bytes_per_sec diff = (Time.now.utc - start) diff = 1 if diff < 1 (body_bytes / diff).round(0) end def bytes_per_sec_human "#{Utilities.bytes_to_h(bytes_per_sec)}/s" end def body_bytes_human Utilities.bytes_to_h(body_bytes) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
consul-templaterb-1.5.5 | lib/consul/async/stats.rb |
consul-templaterb-1.5.4 | lib/consul/async/stats.rb |