Class: BasicJRPC::Server
- Inherits:
-
Object
- Object
- BasicJRPC::Server
- Defined in:
- lib/basicjrpc.rb
Instance Method Summary collapse
-
#initialize(queue, injected_class) ⇒ Server
constructor
A new instance of Server.
- #listen ⇒ Object
Constructor Details
#initialize(queue, injected_class) ⇒ Server
Returns a new instance of Server.
37 38 39 40 41 |
# File 'lib/basicjrpc.rb', line 37 def initialize queue, injected_class @injected_class = injected_class @queue = queue @redis = Redis.new end |
Instance Method Details
#listen ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/basicjrpc.rb', line 43 def listen puts "Listening..." while true payload = @redis.blpop(@queue)[1] payload = Oj.load(payload) # Should always return a data object response = @injected_class.send(payload.method_name, *payload.args) # Bounce the response back @redis.rpush(payload., Oj.dump(response)) end end |