Class: WAMP::Engines::Redis

Inherits:
Memory
  • Object
show all
Defined in:
lib/wamp/engines/redis.rb

Constant Summary collapse

DEFAULT_HOST =
'localhost'
DEFAULT_PORT =
6379
DEFAULT_DATABASE =
0
DEFAULT_GC =
60
LOCK_TIMEOUT =
120

Instance Attribute Summary collapse

Attributes inherited from Memory

#options

Instance Method Summary collapse

Methods inherited from Memory

#all_clients, #create_client, #delete_client, #find_clients, #find_or_create_topic, #subscribe_client_to_topic, #unsubscribe_client_from_topic

Constructor Details

#initialize(options) ⇒ Redis

Creates a new instance of the Redis engine and sets up the connections to the Redis server



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/wamp/engines/redis.rb', line 17

def initialize(options)
  super

  @host      = options[:host]     || DEFAULT_HOST
  @port      = options[:port]     || DEFAULT_PORT
  @database  = options[:database] || DEFAULT_DATABASE
  @gc        = options[:gc]       || DEFAULT_GC
  @password  = options[:password]
  @namespace = options[:namespace] || ''

  @clients_ns  = @namespace + ":clients"
  @topics_ns   = @namespace + ":topics"
  @prefixes_ns = @namespace + ":prefixes"
  @events_ns   = @namespace + ":events"

  @completed_events = []

  @redis      = ::Redis.new(host: @host, port: @port)
  @subscriber = ::Redis.new(host: @host, port: @port)

  if @password
    @redis.auth(@password)
    @subscriber.auth(@password)
  end

  @redis.select(@database)
  @subscriber.select(@database)

  redis_subscribe_to_events
end

Instance Attribute Details

#clientsObject

Returns the value of attribute clients.



7
8
9
# File 'lib/wamp/engines/redis.rb', line 7

def clients
  @clients
end

#topicsObject

Returns the value of attribute topics.



7
8
9
# File 'lib/wamp/engines/redis.rb', line 7

def topics
  @topics
end

Instance Method Details

#create_event(client, topic_uri, payload, excluded, included) ⇒ Object



48
49
50
# File 'lib/wamp/engines/redis.rb', line 48

def create_event(client, topic_uri, payload, excluded, included)
  redis_create_event(client.id, topic_uri, protocol, payload, excluded, included)
end