Class: Stargate::Client::Protocol::Inproc

Inherits:
Stargate::Client::Protocol show all
Defined in:
lib/stargate/client/protocol/inproc.rb

Overview

Internal: A client implementation compatible with Inproc server engine.

Constant Summary collapse

RegistryNotFoundError =
Class.new(::Stargate::Client::Error)

Constants inherited from Stargate::Client::Protocol

DEFAULT_TIMEOUT, UnsupportedProtocolError

Instance Attribute Summary

Attributes inherited from Stargate::Client::Protocol

#codec, #options, #safe_uri, #uri

Instance Method Summary collapse

Methods inherited from Stargate::Client::Protocol

[], register, transports

Constructor Details

#initializeInproc

Returns a new instance of Inproc.


9
10
11
12
13
14
# File 'lib/stargate/client/protocol/inproc.rb', line 9

def initialize(*)
  super
  @registry_version = ::Stargate::INPROC[uri.to_s]
  @caller = ::Stargate::Server::Caller.new(@registry_version)
  raise RegistryNotFoundError, "Local registry not found: #{uri.to_s}" unless @registry_version
end

Instance Method Details

#call(klass, method, *args) ⇒ Object


20
21
22
23
24
# File 'lib/stargate/client/protocol/inproc.rb', line 20

def call(klass, method, *args)
  unpack_payload(@caller.call(klass.remote_name, method, *args))
rescue => err
  raise RemoteExecutionError.new(err.class.to_s, err.message)
end

#fetch_definitionsObject


16
17
18
# File 'lib/stargate/client/protocol/inproc.rb', line 16

def fetch_definitions
  unpack_definitions(@registry_version.definitions.map(&:serialize))
end