Sha256: b75cdca6510946712b9c4673668b99584dd3b1c60c4fc851e1e4101cc22efc7a
Contents?: true
Size: 951 Bytes
Versions: 3
Compression:
Stored size: 951 Bytes
Contents
require 'rinda/rinda' require 'rubyonacid/factory' module RubyOnAcid class RindaFactory < Factory #Time in seconds to wait for a value before giving up and returning the last retrieved value for the given key. #Default is 0, which will return immediately. attr_accessor :timeout #The URI to connect to. Default is "druby://127.0.0.1:7632" (7632 == RNDA). attr_accessor :uri def initialize(uri = "druby://127.0.0.1:7632", timeout = 0) super @uri = uri @timeout = timeout @prior_values = {} end def start_service DRb.start_service @space = Rinda::TupleSpaceProxy.new(DRbObject.new(nil, @uri)) end #Get key from Rinda server. def get_unit(key) @prior_values[key] ||= 0.0 begin key, value = @space.take([key, Float], @timeout) @prior_values[key] = value rescue Rinda::RequestExpiredError => exception value = @prior_values[key] end value end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rubyonacid-0.1.2 | lib/rubyonacid/factories/rinda.rb |
rubyonacid-0.1.1 | lib/rubyonacid/factories/rinda.rb |
rubyonacid-0.1.0 | lib/rubyonacid/factories/rinda.rb |