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) ⇒ Client

Constructor.

Parameters:

Since:

  • 0.2.0



36
37
38
# File 'lib/qrpc/client.rb', line 36

def initialize(locator)
    @dispatcher = QRPC::Client::Dispatcher::new(locator)
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_json method.

Parameters:

  • name (Symbol)

    name of the called methods

  • args (Array)

    arguments of the called methods

  • block (Proc)

    callback for returning result

Since:

  • 0.2.0



51
52
53
# File 'lib/qrpc/client.rb', line 51

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



28
29
30
# File 'lib/qrpc/client.rb', line 28

def dispatcher
  @dispatcher
end