nchan_tools 0.1.6 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/nchan-redis-debug +13 -19
- data/lib/nchan_tools/rdsck.rb +15 -4
- data/lib/nchan_tools/version.rb +1 -1
- data/nchan_tools.gemspec +3 -2
- metadata +24 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65a7cdf81145f3dde05ac13e82dc9dcc09063eff263ec642a6b9e3682db033d1
|
4
|
+
data.tar.gz: 5d8d9ff2c06a5ebd982a123be59a3ed13310b99c7daa869e86e30832f69ee509
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b771ba51b4108c2c01805e06730590c79f5150180d62bad58662e7f6f6f1ed250257c94acf992274292195381262ca01164f249df147ba3eabd149f0ad730259
|
7
|
+
data.tar.gz: 5b422326b465e2df1f70315edad5dda73766c861aa18f4d65cbc64093bbf229a2a0845de7f207620751442e6a6b47887ebfd44f5002757ef2abf6c690220b0fe
|
data/exe/nchan-redis-debug
CHANGED
@@ -4,32 +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
|
-
def dbg(...)
|
14
|
-
if $opt[:verbose]
|
15
|
-
print("# ")
|
16
|
-
puts(...)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
13
|
opt_parser=OptionParser.new do |opts|
|
21
|
-
opts.on("--url", "--url REDIS_URL (#{
|
22
|
-
|
14
|
+
opts.on("--url", "--url REDIS_URL (#{opt[:url]})", "Redis server and port..") do |v|
|
15
|
+
opt[:url]=v
|
23
16
|
end
|
24
17
|
opts.on("-q", "--quiet", "output only results without any other information") do
|
25
|
-
|
18
|
+
opt[:quiet]=false
|
19
|
+
opts[:verbose] = !opt[:quiet]
|
26
20
|
end
|
27
21
|
opts.on("--list-channels", "list all Nchan channels on Redis server or cluster") do |v|
|
28
|
-
|
22
|
+
opt[:command]=:filter_channels
|
29
23
|
end
|
30
24
|
opts.on("--filter-channels-min-subscribers=[NUMBER]") do |v|
|
31
|
-
|
32
|
-
|
25
|
+
opt[:command]=:filter_channels
|
26
|
+
opt[:min_subscribers]=v.to_i
|
33
27
|
end
|
34
28
|
end
|
35
29
|
opt_parser.banner= <<~EOB
|
@@ -46,16 +40,16 @@ opt_parser.banner= <<~EOB
|
|
46
40
|
EOB
|
47
41
|
opt_parser.parse!
|
48
42
|
|
49
|
-
rdsck = Rdsck.new
|
43
|
+
rdsck = Rdsck.new opt
|
50
44
|
if not rdsck.connect
|
51
|
-
STDERR.puts "failed to connect to #{
|
45
|
+
STDERR.puts "failed to connect to #{opt[:url]}"
|
52
46
|
exit 1
|
53
47
|
end
|
54
48
|
|
55
|
-
case
|
49
|
+
case opt[:command]
|
56
50
|
when :filter_channels
|
57
|
-
puts "# scanning for channels #{
|
58
|
-
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])
|
59
53
|
puts "# found #{chans.count} channel#{chans.count != 1 && "s"}#{chans.count == 0 ? "." : ":"}"
|
60
54
|
puts chans.join("\n")
|
61
55
|
else
|
data/lib/nchan_tools/rdsck.rb
CHANGED
@@ -1,10 +1,19 @@
|
|
1
1
|
class Rdsck
|
2
2
|
attr_accessor :url, :verbose, :namespace
|
3
3
|
attr_accessor :redis, :masters
|
4
|
+
|
5
|
+
def dbg(*args)
|
6
|
+
if @verbose
|
7
|
+
print("# ")
|
8
|
+
puts(*args)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
4
12
|
def initialize(opt)
|
5
13
|
@url=opt[:url]
|
6
14
|
@verbose=opt[:verbose]
|
7
15
|
@namespace=opt[:namespace]
|
16
|
+
@channel_id=opt[:channel_id]
|
8
17
|
end
|
9
18
|
|
10
19
|
def cluster?
|
@@ -13,7 +22,8 @@ class Rdsck
|
|
13
22
|
|
14
23
|
def connect
|
15
24
|
begin
|
16
|
-
|
25
|
+
puts "connect to #{@url}"
|
26
|
+
@redis=Redis.new url: @url
|
17
27
|
mode = redis.info["redis_mode"]
|
18
28
|
rescue StandardError => e
|
19
29
|
STDERR.puts e.message
|
@@ -23,7 +33,8 @@ class Rdsck
|
|
23
33
|
if mode == "cluster"
|
24
34
|
@redis.close
|
25
35
|
begin
|
26
|
-
|
36
|
+
puts "cluster-connect to #{@url}"
|
37
|
+
@redis=Redis.new cluster: [@url]
|
27
38
|
@redis.ping
|
28
39
|
rescue StandardError => e
|
29
40
|
STDERR.puts e.message
|
@@ -49,7 +60,7 @@ class Rdsck
|
|
49
60
|
end
|
50
61
|
|
51
62
|
def key(subkey=nil)
|
52
|
-
k = "{channel:#{
|
63
|
+
k = "{channel:#{@namespace}/#{@channel_id}}"
|
53
64
|
return subkey ? "#{k}:#{subkey}" : k
|
54
65
|
end
|
55
66
|
|
@@ -90,7 +101,7 @@ class Rdsck
|
|
90
101
|
EOF
|
91
102
|
|
92
103
|
results = []
|
93
|
-
batch_size=
|
104
|
+
batch_size=500
|
94
105
|
masters.each do |m|
|
95
106
|
hash = m.script "load", script
|
96
107
|
cursor, pattern = "0", "{channel:*}"
|
data/lib/nchan_tools/version.rb
CHANGED
data/nchan_tools.gemspec
CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_dependency "celluloid"
|
30
30
|
spec.add_dependency "celluloid-io"
|
31
31
|
spec.add_dependency "HDRHistogram"
|
32
|
+
spec.add_dependency "redis", "~>4.2.0"
|
32
33
|
|
33
34
|
spec.add_dependency "websocket-driver"
|
34
35
|
spec.add_dependency 'websocket-extensions'
|
@@ -38,6 +39,6 @@ Gem::Specification.new do |spec|
|
|
38
39
|
spec.add_dependency 'http-2'
|
39
40
|
end
|
40
41
|
spec.add_development_dependency "pry"
|
41
|
-
spec.add_development_dependency "bundler"
|
42
|
-
spec.add_development_dependency "rake"
|
42
|
+
spec.add_development_dependency "bundler"
|
43
|
+
spec.add_development_dependency "rake"
|
43
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nchan_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leo Ponomarev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: redis
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 4.2.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 4.2.0
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: websocket-driver
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,30 +196,30 @@ dependencies:
|
|
182
196
|
name: bundler
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
184
198
|
requirements:
|
185
|
-
- - "
|
199
|
+
- - ">="
|
186
200
|
- !ruby/object:Gem::Version
|
187
|
-
version: '
|
201
|
+
version: '0'
|
188
202
|
type: :development
|
189
203
|
prerelease: false
|
190
204
|
version_requirements: !ruby/object:Gem::Requirement
|
191
205
|
requirements:
|
192
|
-
- - "
|
206
|
+
- - ">="
|
193
207
|
- !ruby/object:Gem::Version
|
194
|
-
version: '
|
208
|
+
version: '0'
|
195
209
|
- !ruby/object:Gem::Dependency
|
196
210
|
name: rake
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
198
212
|
requirements:
|
199
|
-
- - "
|
213
|
+
- - ">="
|
200
214
|
- !ruby/object:Gem::Version
|
201
|
-
version: '
|
215
|
+
version: '0'
|
202
216
|
type: :development
|
203
217
|
prerelease: false
|
204
218
|
version_requirements: !ruby/object:Gem::Requirement
|
205
219
|
requirements:
|
206
|
-
- - "
|
220
|
+
- - ">="
|
207
221
|
- !ruby/object:Gem::Version
|
208
|
-
version: '
|
222
|
+
version: '0'
|
209
223
|
description: publishing, subscribing, testing, and benchmarking utilities for Nchan.
|
210
224
|
email:
|
211
225
|
- leo@nchan.io
|