Class: SGS::RPCClient

Inherits:
Object
  • Object
show all
Defined in:
lib/sgs/rpc.rb

Instance Method Summary collapse

Constructor Details

#initialize(channel) ⇒ RPCClient

Returns a new instance of RPCClient.



46
47
48
# File 'lib/sgs/rpc.rb', line 46

def initialize(channel)
  @channel = channel.to_s
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/sgs/rpc.rb', line 50

def method_missing(name, *args)
  uuid = SecureRandom.uuid
  request = {
    'id' => uuid,
    'jsonrpc' => '2.0',
    'method' => name,
    'params' => args
  }
  puts "RPC CLIENT SENDING MESSAGE! request: #{request.inspect}, channel: #{@channel}"
  RedisBase.redis.lpush(@channel, request.to_msgpack)
end