Module: Hsdq::Connectors

Included in:
Hsdq, Listener, Sender
Defined in:
lib/hsdq/connectors.rb

Overview

This module contains the logic for different connection to the redis layer.

They can be connected to the same Redis instance, but it is recommended to use different database connections in order to segregate the different usages.

In production of large applications you should use different instances for the different layers. The configuration files are named after your class name hsdq_yourclass.yml

Instance Method Summary collapse

Instance Method Details

#cx_adminRedis connection

establish a connection for the admin channel pub/sub

Returns:

  • (Redis connection)

    reserved for the admin commands



36
37
38
# File 'lib/hsdq/connectors.rb', line 36

def cx_admin
  @cx_admin ||= Redis.new cx_opts[:admin]
end

#cx_dataRedis connection

Establish an unblocked connection for the sender and also pulling data from Redis

Returns:

  • (Redis connection)

    This connection is used to send messages as well as to retrieve data from the message hash



24
25
26
# File 'lib/hsdq/connectors.rb', line 24

def cx_data
  @cx_data ||= Redis.new cx_opts[:message]
end

#cx_listenerRedis connection

Establish the listener connection. IMPORTANT this connection is blocked by the listener and must not be used elsewhere

Returns:

  • (Redis connection)

    For the listener exclusively



17
18
19
# File 'lib/hsdq/connectors.rb', line 17

def cx_listener
  @cx_listener ||= Redis.new cx_opts[:message]
end

#cx_sessionRedis connection

establish an unblocked connection for the session layer

Returns:

  • (Redis connection)

    reserved for storing and retrieving the sessions data



30
31
32
# File 'lib/hsdq/connectors.rb', line 30

def cx_session
  @cx_session ||= Redis.new cx_opts[:session]
end