module Cannon::Rpc::RemoteService(T)

Overview

Include this into a client class to access a specific remote service through a Connection.

The T is the description module. For all public methods in T a method will be generated, which forwards the call to the remote end. By default, the invocation will wait for a response to return it, or to raise a RemoteError when an error occured. Each method also exists in a without_response version, which if used, will not wait for the remote end to finish the work. This also means that any result (or encountered error) will be silently dropped.

Calling Example

my_service = MyServiceClient.new(my_connection, the_identifier)
pp my_service.greet("You")                  # Will wait for the response
pp my_service.greet_without_response("You") # Will NOT wait

Please see samples/rpc for a complete usage example.

Defined in:

cannon/rpc/remote_service.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(connection : Connection, service_id : UInt32, owned : Bool = false) #

Instantiates a client over connection to the service.


[View source]

Instance Method Detail

def connection : Connection #

The connection used to reach the remote Service object


[View source]
def finalize #

Release the remote service on garbage-collection.


[View source]
def owned? : Bool #

Do we own this service?


[View source]
def release_now! #

Releases ("free's") the remote service if we own it. Automatically called on #finalize, so it's done automatically when this object is garbage-collected.


[View source]
def service_id : UInt32 #

The id of the remote Service object


[View source]