Sha256: 34839b4142c734219d2bc0d1139951b0d49a0a30aef5ddc1989b5ea8a49f8d45

Contents?: true

Size: 807 Bytes

Versions: 8

Compression:

Stored size: 807 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'

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

    bean_add_child(:timer, @timer)

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rumx-0.2.3 examples/timer/my_bean.rb
rumx-0.2.2 examples/timer/my_bean.rb
rumx-0.1.5 examples/timer/my_bean.rb
rumx-0.1.4 examples/timer/my_bean.rb
rumx-0.1.3 examples/timer/my_bean.rb
rumx-0.1.2 examples/timer/my_bean.rb
rumx-0.1.1 examples/timer/my_bean.rb
rumx-0.1.0 examples/timer/my_bean.rb