Class: Msngr::Clients::Redis

Inherits:
Object
  • Object
show all
Defined in:
lib/msngr/clients/redis.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Redis

Instantiances an instance of Msngr::Clients::Redis.

Parameters:

  • *args (Array)

    the arguments to pass in to the Redis client.



15
16
17
# File 'lib/msngr/clients/redis.rb', line 15

def initialize(*args)
  @args = args
end

Instance Attribute Details

#argsArray (readonly)

(Connectivity) Arguments to initialize the Redis instance with.

Returns:

  • (Array)


9
10
11
# File 'lib/msngr/clients/redis.rb', line 9

def args
  @args
end

Instance Method Details

#on_message {|event, message| ... } ⇒ Object

Note:

This is an interface for Msngr::Messenger.

Yields all events/messages from the Redis server.

Yields:

  • (event, message)

Yield Parameters:

  • event (String)

    the name of the received event.

  • message (String)

    the message of the received event.



27
28
29
30
31
# File 'lib/msngr/clients/redis.rb', line 27

def on_message
  connection.psubscribe("*") do |on|
    on.pmessage { |_, event, message| yield event, message }
  end
end