em-hiredis-sentinel 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/em-hiredis-sentinel/base_client.rb +2 -12
- data/lib/em-hiredis-sentinel/pubsub_client.rb +0 -1
- data/lib/em-hiredis-sentinel/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12da4ece90b62751bab33970653fc6646597c5ab
|
4
|
+
data.tar.gz: 5df06626c12576441d7ec5fe3a18465f5dd5d44c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ecdcce6e55f24b4a0b31346dd5512c5009fd3432fb31efd459b3c23fb8a980429110dda986ad8f5d05e29842dd0a5f34f22e1ce415dac090c1dd9b83dade89a
|
7
|
+
data.tar.gz: 38223becb9dfc216e004da3009fc46a6525f89253349c2ed2da9da06023392637489debd842172b45f650087755d13e6b8d6ca59d8901ffdf65ea137a24842c0
|
data/README.md
CHANGED
@@ -4,8 +4,7 @@ module EventMachine::Hiredis
|
|
4
4
|
attr_reader :sentinel_options
|
5
5
|
|
6
6
|
def initialize_with_sentinel(host = 'localhost', port = 6379, password = nil, db = nil, sentinel_options={})
|
7
|
-
|
8
|
-
puts "SentinelOptions: #{sentinel_options}"
|
7
|
+
|
9
8
|
initialize_without_sentinel(host,port,password,db)
|
10
9
|
if sentinel_options.nil? || sentinel_options.empty?
|
11
10
|
return
|
@@ -34,15 +33,11 @@ module EventMachine::Hiredis
|
|
34
33
|
pubsub.punsubscribe('*')
|
35
34
|
pubsub.psubscribe('*')
|
36
35
|
pubsub.on(:pmessage) { |pattern, channel, message|
|
37
|
-
puts "Channel:#{channel}"
|
38
|
-
puts "Message:#{message}"
|
39
36
|
next if channel != '+switch-master'
|
40
37
|
|
41
38
|
master_name, old_host, old_port, new_host, new_port = message.split(" ")
|
42
39
|
|
43
40
|
next if master_name != @master_name
|
44
|
-
|
45
|
-
#@options.merge!(host: new_host, port: new_port.to_i)
|
46
41
|
EM::Hiredis.logger.info("Failover: #{old_host}:#{old_port} => #{new_host}:#{new_port}")
|
47
42
|
close_connection
|
48
43
|
@host, @port = new_host,new_port.to_i
|
@@ -55,18 +50,16 @@ module EventMachine::Hiredis
|
|
55
50
|
sentinel_options = @sentinels_options.shift
|
56
51
|
@sentinels_options.push sentinel_options
|
57
52
|
|
58
|
-
|
53
|
+
EM::Hiredis.logger.info("Trying next sentinel: #{sentinel_options[:host]}:#{sentinel_options[:port]}")
|
59
54
|
@current_sentinel.close_connection
|
60
55
|
@current_sentinel.configure("redis://#{sentinel_options[:host]}:#{sentinel_options[:port]}")
|
61
56
|
@current_sentinel.reconnect_connection
|
62
57
|
unless @switching_sentinels
|
63
58
|
@switching_sentinels = true
|
64
59
|
@sentinel_timer = EM.add_periodic_timer(1) {
|
65
|
-
puts 'Trying New Sentinel Connection'
|
66
60
|
if @current_sentinel.connected?
|
67
61
|
@switching_sentinels = false
|
68
62
|
@sentinel_timer.cancel
|
69
|
-
#watch_sentinel
|
70
63
|
else
|
71
64
|
try_next_sentinel
|
72
65
|
end
|
@@ -81,9 +74,6 @@ module EventMachine::Hiredis
|
|
81
74
|
|
82
75
|
if master_host && master_port
|
83
76
|
|
84
|
-
# An ip:port pair
|
85
|
-
#@options.merge!(:host => master_host, :port => master_port.to_i, :password => @master_password)
|
86
|
-
#close_connection
|
87
77
|
@host, @port = master_host,master_port.to_i
|
88
78
|
reconnect_connection
|
89
79
|
refresh_sentinels_list
|
@@ -2,7 +2,6 @@ module EventMachine::Hiredis
|
|
2
2
|
class PubsubClient < BaseClient
|
3
3
|
class_eval {
|
4
4
|
def initialize(host='localhost', port='6379', password=nil, db=nil, sentinel_options={})
|
5
|
-
puts "Initializing with sentinel: #{sentinel_options}"
|
6
5
|
@subs, @psubs = [], []
|
7
6
|
@pubsub_defs = Hash.new { |h,k| h[k] = [] }
|
8
7
|
super
|