nchan_tools 0.1.9 → 0.1.10
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/exe/nchan-redis-debug +13 -12
- data/lib/nchan_tools/rdsck.rb +5 -4
- data/lib/nchan_tools/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e17f44cb591b9f74d1791e1f9ec8574613fbc840c6aac91953c8a526a8a63006
|
4
|
+
data.tar.gz: 405aabdbc70b14571c6cc545ca13f0ea7e5ad65b130ab37194fee1ed7ccf7d5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31e391ad81b9a43519d014a538f77b87b25706a009180b83239eea014c174497d8d7e3c9ca26d173b075cd42cba4e82ab92dc696ce459058080a325c29f808e3
|
7
|
+
data.tar.gz: 66654049eaf6f7f26e16fd98df88b1570a5d80f7168cc2f774e5d7168ae4d42a668b1384c3280fd82b8473f78e63ec4774b005f9971be4db7e9a2d4d65a01264
|
data/exe/nchan-redis-debug
CHANGED
@@ -4,25 +4,26 @@ require "redis"
|
|
4
4
|
require "optparse"
|
5
5
|
require 'nchan_tools/rdsck'
|
6
6
|
|
7
|
-
|
7
|
+
opt = {
|
8
8
|
url: "redis://127.0.0.1:6379/",
|
9
9
|
verbose: false,
|
10
10
|
command: nil
|
11
11
|
}
|
12
12
|
|
13
13
|
opt_parser=OptionParser.new do |opts|
|
14
|
-
opts.on("--url", "--url REDIS_URL (#{
|
15
|
-
|
14
|
+
opts.on("--url", "--url REDIS_URL (#{opt[:url]})", "Redis server and port..") do |v|
|
15
|
+
opt[:url]=v
|
16
16
|
end
|
17
17
|
opts.on("-q", "--quiet", "output only results without any other information") do
|
18
|
-
|
18
|
+
opt[:quiet]=false
|
19
|
+
opts[:verbose] = !opt[:quiet]
|
19
20
|
end
|
20
21
|
opts.on("--list-channels", "list all Nchan channels on Redis server or cluster") do |v|
|
21
|
-
|
22
|
+
opt[:command]=:filter_channels
|
22
23
|
end
|
23
24
|
opts.on("--filter-channels-min-subscribers=[NUMBER]") do |v|
|
24
|
-
|
25
|
-
|
25
|
+
opt[:command]=:filter_channels
|
26
|
+
opt[:min_subscribers]=v.to_i
|
26
27
|
end
|
27
28
|
end
|
28
29
|
opt_parser.banner= <<~EOB
|
@@ -39,16 +40,16 @@ opt_parser.banner= <<~EOB
|
|
39
40
|
EOB
|
40
41
|
opt_parser.parse!
|
41
42
|
|
42
|
-
rdsck = Rdsck.new
|
43
|
+
rdsck = Rdsck.new opt
|
43
44
|
if not rdsck.connect
|
44
|
-
STDERR.puts "failed to connect to #{
|
45
|
+
STDERR.puts "failed to connect to #{opt[:url]}"
|
45
46
|
exit 1
|
46
47
|
end
|
47
48
|
|
48
|
-
case
|
49
|
+
case opt[:command]
|
49
50
|
when :filter_channels
|
50
|
-
puts "# scanning for channels #{
|
51
|
-
chans = rdsck.filter_channels(min_subscribers:
|
51
|
+
puts "# scanning for channels #{opt[:min_subscribers] && "with subscribers >= #{opt[:min_subscribers]}"}"
|
52
|
+
chans = rdsck.filter_channels(min_subscribers: opt[:min_subscribers])
|
52
53
|
puts "# found #{chans.count} channel#{chans.count != 1 && "s"}#{chans.count == 0 ? "." : ":"}"
|
53
54
|
puts chans.join("\n")
|
54
55
|
else
|
data/lib/nchan_tools/rdsck.rb
CHANGED
@@ -3,7 +3,7 @@ class Rdsck
|
|
3
3
|
attr_accessor :redis, :masters
|
4
4
|
|
5
5
|
def dbg(*args)
|
6
|
-
if
|
6
|
+
if @verbose
|
7
7
|
print("# ")
|
8
8
|
puts(*args)
|
9
9
|
end
|
@@ -13,6 +13,7 @@ class Rdsck
|
|
13
13
|
@url=opt[:url]
|
14
14
|
@verbose=opt[:verbose]
|
15
15
|
@namespace=opt[:namespace]
|
16
|
+
@channel_id=opt[:channel_id]
|
16
17
|
end
|
17
18
|
|
18
19
|
def cluster?
|
@@ -21,7 +22,7 @@ class Rdsck
|
|
21
22
|
|
22
23
|
def connect
|
23
24
|
begin
|
24
|
-
@redis=Redis.new url:
|
25
|
+
@redis=Redis.new url: @url
|
25
26
|
mode = redis.info["redis_mode"]
|
26
27
|
rescue StandardError => e
|
27
28
|
STDERR.puts e.message
|
@@ -31,7 +32,7 @@ class Rdsck
|
|
31
32
|
if mode == "cluster"
|
32
33
|
@redis.close
|
33
34
|
begin
|
34
|
-
@redis=Redis.new cluster: [
|
35
|
+
@redis=Redis.new cluster: [@url]
|
35
36
|
@redis.ping
|
36
37
|
rescue StandardError => e
|
37
38
|
STDERR.puts e.message
|
@@ -57,7 +58,7 @@ class Rdsck
|
|
57
58
|
end
|
58
59
|
|
59
60
|
def key(subkey=nil)
|
60
|
-
k = "{channel:#{
|
61
|
+
k = "{channel:#{@namespace}/#{@channel_id}}"
|
61
62
|
return subkey ? "#{k}:#{subkey}" : k
|
62
63
|
end
|
63
64
|
|
data/lib/nchan_tools/version.rb
CHANGED