Sha256: e59f54b1467bcd54927ab98286b2a22a4580682ec66843e5d1e211a2a5d5328d

Contents?: true

Size: 841 Bytes

Versions: 3

Compression:

Stored size: 841 Bytes

Contents

class MyBean
  include Rumx::Bean

  bean_attr_accessor :sleep_time,      :float,   'Amount of time in seconds my measured block sleeps'
  bean_attr_accessor :percent_failure, :integer, 'Percentage of time the measured block will fail'
  bean_attr_embed    :timer,                     'Timer for our sleep action'

  def initialize
    @sleep_time      = 0.5
    @percent_failure = 10
    @timer           = Rumx::Beans::Timer.new(:max_errors => 5)

    Thread.new do
      while true
        begin
          @timer.measure do
            if rand(100) < @percent_failure
              raise "Failure occurred with sleep_time=#{@sleep_time} and percent failure=#{@percent_failure}"
            end
            sleep @sleep_time
          end
        rescue Exception => e
          # Error handling...
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rumx-0.0.5 examples/timer/my_bean.rb
rumx-0.0.4 examples/timer/my_bean.rb
rumx-0.0.3 examples/timer/my_bean.rb