Class: RedisClient::PubSub
- Inherits:
-
Object
- Object
- RedisClient::PubSub
- Defined in:
- lib/redis_client.rb
Instance Method Summary collapse
- #call(*command, **kwargs) ⇒ Object
- #call_v(command) ⇒ Object
- #close ⇒ Object
-
#initialize(raw_connection, command_builder) ⇒ PubSub
constructor
A new instance of PubSub.
- #next_event(timeout = nil) ⇒ Object
Constructor Details
#initialize(raw_connection, command_builder) ⇒ PubSub
Returns a new instance of PubSub.
487 488 489 490 |
# File 'lib/redis_client.rb', line 487 def initialize(raw_connection, command_builder) @raw_connection = raw_connection @command_builder = command_builder end |
Instance Method Details
#call(*command, **kwargs) ⇒ Object
492 493 494 495 |
# File 'lib/redis_client.rb', line 492 def call(*command, **kwargs) raw_connection.write(@command_builder.generate(command, kwargs)) nil end |
#call_v(command) ⇒ Object
497 498 499 500 |
# File 'lib/redis_client.rb', line 497 def call_v(command) raw_connection.write(@command_builder.generate(command)) nil end |
#close ⇒ Object
502 503 504 505 506 |
# File 'lib/redis_client.rb', line 502 def close @raw_connection&.close @raw_connection = nil # PubSub can't just reconnect self end |
#next_event(timeout = nil) ⇒ Object
508 509 510 511 512 513 514 515 516 |
# File 'lib/redis_client.rb', line 508 def next_event(timeout = nil) unless raw_connection raise ConnectionError, "Connection was closed or lost" end raw_connection.read(timeout) rescue ReadTimeoutError nil end |