Sha256: b4ffe498ddcbbbb3fd2ee8f6176da7ba312c41cb825fcc3c77112a5f5e32bd7f

Contents?: true

Size: 650 Bytes

Versions: 22

Compression:

Stored size: 650 Bytes

Contents

require "cabin/namespace"
require "cabin/timer"

module Cabin::Mixins::Timer
  # Start timing something.
  # Returns an instance of Cabin::Timer bound to this Cabin::Channel.
  # To stop the timer and immediately emit the result to this channel, invoke
  # the Cabin::Timer#stop method.
  def time(data, &block)
    # TODO(sissel): need to refactor string->hash shoving.
    data = dataify(data)

    timer = Cabin::Timer.new do |duration|
      data[:duration] = duration
      publish(data)
    end

    if block_given?
      block.call
      return timer.stop
    else
      return timer
    end
  end # def time
end # module Cabin::Mixins::Timer

Version data entries

22 entries across 20 versions & 6 rubygems

Version Path
logstash-filter-zabbix-0.1.2 vendor/bundle/jruby/1.9/gems/cabin-0.8.1/lib/cabin/mixins/timer.rb
logstash-filter-zabbix-0.1.1 vendor/bundle/jruby/1.9/gems/cabin-0.8.1/lib/cabin/mixins/timer.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/cabin-0.8.1/lib/cabin/mixins/timer.rb
ivanvc-logstash-input-s3-3.1.1.3 vendor/local/gems/cabin-0.8.1/lib/cabin/mixins/timer.rb
ivanvc-logstash-input-s3-3.1.1.2 vendor/local/gems/cabin-0.8.1/lib/cabin/mixins/timer.rb
cabin-0.9.0 lib/cabin/mixins/timer.rb
able-neo4j-1.0.0 vendor/bundle/jruby/1.9/gems/cabin-0.7.1/lib/cabin/mixins/timer.rb
cabin-0.8.1 lib/cabin/mixins/timer.rb
cabin-0.8.0 lib/cabin/mixins/timer.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/cabin-0.7.2/lib/cabin/mixins/timer.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/logstash-codec-json-2.0.3/vendor/gems/cabin-0.7.2/lib/cabin/mixins/timer.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/cabin-0.7.1/lib/cabin/mixins/timer.rb
logstash-codec-json-2.0.3 vendor/gems/cabin-0.7.2/lib/cabin/mixins/timer.rb
cabin-0.7.2 lib/cabin/mixins/timer.rb
logstash-input-beats-0.9.2 vendor/jruby/1.9/gems/cabin-0.7.1/lib/cabin/mixins/timer.rb
logstash-input-beats-0.9.1 vendor/jruby/1.9/gems/cabin-0.7.1/lib/cabin/mixins/timer.rb
cabin-0.7.1 lib/cabin/mixins/timer.rb
cabin-0.6.1 lib/cabin/mixins/timer.rb
cabin-0.6.0 lib/cabin/mixins/timer.rb
cabin-0.5.0 lib/cabin/mixins/timer.rb