Class: Dizby::SemiObjectProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/dizby/distributed/semi_proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri, ref) ⇒ SemiObjectProxy

Returns a new instance of SemiObjectProxy.



13
14
15
16
# File 'lib/dizby/distributed/semi_proxy.rb', line 13

def initialize(uri, ref)
  @uri = uri
  @ref = ref
end

Instance Method Details

#evaluate(server)



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/dizby/distributed/semi_proxy.rb', line 18

def evaluate(server)
  # cut down on network times by using the object if it exists locally
  success, obj = Dizby.get_obj(@uri, @ref)

  if success
    server.log.debug("found local obj: #{obj.inspect}")
    obj
  else
    server.log.debug("creating proxy to #{@ref} on #{@uri}")
    client, = server.connect_to(@uri) # throw away the ref
    ObjectProxy.new(client, @ref)
  end
end