Class: RedisRpc::Server
- Inherits:
-
Object
- Object
- RedisRpc::Server
- Defined in:
- lib/redis-rpc.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
- #flush_queue! ⇒ Object
-
#initialize(redis_server, message_queue, local_object, timeout: nil, response_expiry: 1, verbose: false, logger: nil) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
- #run! ⇒ Object
- #stop! ⇒ Object
Constructor Details
#initialize(redis_server, message_queue, local_object, timeout: nil, response_expiry: 1, verbose: false, logger: nil) ⇒ Server
Returns a new instance of Server.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/redis-rpc.rb', line 116 def initialize(redis_server, , local_object, timeout: nil, response_expiry: 1, verbose: false, logger: nil) @redis_server = redis_server @message_queue = @local_object = local_object.tap do |o| # Override #respond_to? so it only exposes methods which are directly defined by the receiver def o.respond_to?(method_name) self.public_methods(false).include?(method_name.to_sym) end end @timeout = timeout || 0 @response_expiry = response_expiry @verbose = verbose @logger = logger end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
107 108 109 |
# File 'lib/redis-rpc.rb', line 107 def logger @logger end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
106 107 108 |
# File 'lib/redis-rpc.rb', line 106 def timeout @timeout end |
Instance Method Details
#flush_queue! ⇒ Object
148 149 150 |
# File 'lib/redis-rpc.rb', line 148 def flush_queue! @redis_server.del @message_queue end |
#run ⇒ Object
131 132 133 134 135 136 |
# File 'lib/redis-rpc.rb', line 131 def run catch(:stop!) do loop { run_one } logger&.info("[#{Time.now}] #{self.class.name} : action=run stopped") end end |
#run! ⇒ Object
138 139 140 141 |
# File 'lib/redis-rpc.rb', line 138 def run! flush_queue! run end |