lib/pears/provider/subscription.rb in pears-0.2.0 vs lib/pears/provider/subscription.rb in pears-0.3.0
- old
+ new
@@ -42,19 +42,27 @@
# unsubscribing can be done more gracefully.
def unsubscribe
@subscription.terminate
end
+ def purge
+ unsubscribe
+ true
+ end
+
private
def subscribe
+ nth = 0
@subscription = Thread.new do
- connection.subscribe(channel) do |on|
- on.message do |channel, message|
- load_config
+ loop do
+ connection.subscribe(channel) do |on|
+ on.message { |_channel, _message| load_config }
end
+
+ nth += 1
+ puts "Pears connection was lost for the #{nth}th time"
end
- puts "Redis connection died!"
end
end
def connection
@connection ||= establish_connection