class SGS::RPCClient

Public Class Methods

new(channel) click to toggle source
# File lib/sgs/rpc.rb, line 38
def initialize(channel)
  @channel = channel.to_s
end

Public Instance Methods

method_missing(name, *args) click to toggle source
# File lib/sgs/rpc.rb, line 42
def method_missing(name, *args)
  uuid = SecureRandom.uuid
  request = {
    'id' => uuid,
    'jsonrpc' => '2.0',
    'method' => name,
    'params' => args
  }
  SGS::RedisBase.redis.lpush(@channel, request.to_msgpack)
  channel, response = SGS::RedisBase.redis.brpop(uuid, timeout=60)
  MessagePack.unpack(response)['result']
end