Class: RedisClient::PubSub

Inherits:
Object show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(raw_connection, command_builder) ⇒ PubSub

Returns a new instance of PubSub.



415
416
417
418
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client.rb', line 415

def initialize(raw_connection, command_builder)
  @raw_connection = raw_connection
  @command_builder = command_builder
end

Instance Method Details

#call(*command, **kwargs) ⇒ Object



420
421
422
423
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client.rb', line 420

def call(*command, **kwargs)
  raw_connection.write(@command_builder.generate(command, kwargs))
  nil
end

#call_v(command) ⇒ Object



425
426
427
428
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client.rb', line 425

def call_v(command)
  raw_connection.write(@command_builder.generate(command))
  nil
end

#closeObject



430
431
432
433
434
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client.rb', line 430

def close
  @raw_connection&.close
  @raw_connection = nil
  self
end

#next_event(timeout = nil) ⇒ Object



436
437
438
439
440
441
442
443
444
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client.rb', line 436

def next_event(timeout = nil)
  unless raw_connection
    raise ConnectionError, "Connection was closed or lost"
  end

  raw_connection.read(timeout)
rescue ReadTimeoutError
  nil
end