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.


7
8
9
10
# File 'lib/dizby/distributed/semi_proxy.rb', line 7

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

Instance Method Details

#evaluate(server)


12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/dizby/distributed/semi_proxy.rb', line 12

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