lib/isono/node_modules/rpc_channel.rb
def request(endpoint, command, *args, &blk)
        req = RequestContext.new(endpoint, command, args)
        # the block is to setup the request context prior to sending.
        if blk
          # async
          r = blk.call(req)
          req = r if r.is_a?(RequestContext)
          send_request(req)
          req
        else
          # sync
          req = req.synchronize
          send_request(req)
          req.wait
        end
      end
# Make a RPC request to an endpoint.
#
# @param [String] endpoint
# @param [String] command
# @param [Array] args
# @param [Proc] &blk Block to setup the request context.
# @return [RequestContext,any]
#
# @example create a sync RPC request.
#   rpc.request('endpoint1', 'func1', xxxx)
# @example call RPC in async mode.
#   rpc.request('endpoint1', 'func1', xxxx) { |req|
#     req.on_success { |r|
#       puts r
#     }
#     req.on_error { |r|
#       puts r
#     }
#   }
#
# @example setup request context and do wait().
#   Note that callbacks are
#   rpc.request('endpoint1', 'func1', xxxx) { |req|
#     # send new attribute
#     req.request[:xxxx] = "sdfsdf"
#     # returns synchronized RequestContext to block caller.
#     req.synchronize
#   }.wait # request() get back the altered RequestCotenxt that has wait().
#
# @example Create async oneshot call. (do not expect response)
#   rpc.request('endpoint1', 'func1') { |req|
#     req.oneshot = true
#   }
Make a RPC request to an endpoint.
Make a RPC request to an endpoint .
def request(endpoint, command, *args, &blk)
        req = RequestContext.new(endpoint, command, args)
        if blk
          r = blk.call(req)
          req = r if r.is_a?(RequestContext)
          send_request(req)
          req
        else
          req = req.synchronize
          send_request(req)
          req.wait
        end
      end
def request ( endpoint , command , * args , & blk ) req = RequestContext . new ( endpoint , command , args ) if blk r = blk . call ( req ) req = r if r . is_a? ( RequestContext ) send_request ( req ) req else req = req . synchronize send_request ( req ) req . wait end end
Make a RPC request to an endpoint.
Make a RPC request to an endpoint .
# the block is to setup the request context prior to sending. # async # sync
None
RequestContext,any
endpoint
command
args
blk
&blk Block to setup the request context.
&blk Block to setup the request context .
example
create a sync RPC request. rpc.request('endpoint1', 'func1', xxxx)
create a sync RPC request . rpc . request ( ' endpoint1 ' ' func1 ' xxxx )
example
call RPC in async mode. rpc.request('endpoint1', 'func1', xxxx) { |req| req.on_success { |r| puts r } req.on_error { |r| puts r } }
call RPC in async mode . rpc . request ( ' endpoint1 ' ' func1 ' xxxx ) { |req| req . on_success { |r| puts r } req . on_error { |r| puts r } }
example
setup request context and do wait(). Note that callbacks are rpc.request('endpoint1', 'func1', xxxx) { |req| # send new attribute req.request[:xxxx] = "sdfsdf" # returns synchronized RequestContext to block caller. req.synchronize }.wait # request() get back the altered RequestCotenxt that has wait().
setup request context and do wait () . Note that callbacks are rpc . request ( ' endpoint1 ' ' func1 ' xxxx ) { |req| # send new attribute req . request [ : xxxx ] = " sdfsdf " # returns synchronized RequestContext to block caller . req . synchronize } . wait # request () get back the altered RequestCotenxt that has wait () .
example
Create async oneshot call. (do not expect response) rpc.request('endpoint1', 'func1') { |req| req.oneshot = true }
Create async oneshot call . ( do not expect response ) rpc . request ( ' endpoint1 ' ' func1 ' ) { |req| req . oneshot = true }