Class: QRPC::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/qrpc/client.rb,
lib/qrpc/client/job.rb,
lib/qrpc/client/exception.rb,
lib/qrpc/client/dispatcher.rb

Overview

Note:

Since 0.3.0, all non-system methods was moved to the Dispatcher module for maximal avoiding the user API name conflicts.

Queue RPC client.

Since:

  • 0.2.0

Defined Under Namespace

Classes: Dispatcher, Exception, Job

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locator, generator = QRPC::default_generator, protocol = QRPC::default_protocol) ⇒ Client

Constructor.

Parameters:

Since:

  • 0.2.0



43
44
45
# File 'lib/qrpc/client.rb', line 43

def initialize(locator, generator = QRPC::default_generator, protocol = QRPC::default_protocol)
    @dispatcher = QRPC::Client::Dispatcher::new(locator, generator, protocol)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object

Handles call to RPC. (*********)

Be warn, arguments will be serialized to JSON, so they should be serializable nativelly or implement #to_s or #to_json method.

Parameters:

  • name (Symbol)

    name of the called methods

  • args (Array)

    arguments of the called methods

  • block (Proc)

    callback for returning

Since:

  • 0.2.0



59
60
61
# File 'lib/qrpc/client.rb', line 59

def method_missing(name, *args, &block)
    @dispatcher.put(@dispatcher.create_job(name, args, &block))
end

Instance Attribute Details

#dispatcherDispatcher

Holds working dispatcher.

Returns:

Since:

  • 0.3.0



32
33
34
# File 'lib/qrpc/client.rb', line 32

def dispatcher
  @dispatcher
end