Class: Cnf::Watcher

Inherits:
Object
  • Object
show all
Defined in:
lib/cnf/watcher.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWatcher

Returns a new instance of Watcher.



12
13
14
# File 'lib/cnf/watcher.rb', line 12

def initialize
  @redis = Redis.new(url: ENV["REDIS_PUBSUB_URL"])
end

Instance Attribute Details

#redisObject (readonly)

Returns the value of attribute redis.



10
11
12
# File 'lib/cnf/watcher.rb', line 10

def redis
  @redis
end

Class Method Details

.callObject



6
7
8
# File 'lib/cnf/watcher.rb', line 6

def self.call
  new().call
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
# File 'lib/cnf/watcher.rb', line 20

def call
  keep_connecting(redis) do
    redis.subscribe(channel) do |on|
      on.message do |_, msg|
        on_message_received(msg)
      end
    end
  end
end

#channelObject



16
17
18
# File 'lib/cnf/watcher.rb', line 16

def channel
  "console"
end

#on_message_received(_) ⇒ Object

Raises:

  • (NotImplementedError)


30
31
32
# File 'lib/cnf/watcher.rb', line 30

def on_message_received(_)
  raise NotImplementedError.new
end