graphql-anycable 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -4
- data/README.md +4 -1
- data/graphql-anycable.gemspec +4 -4
- data/lib/graphql/anycable/config.rb +1 -0
- data/lib/graphql/anycable/tasks/clean_expired_subscriptions.rake +47 -25
- data/lib/graphql/anycable/version.rb +1 -1
- metadata +24 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79ed158f4e882659ca963af6a22fb66ce34dfa9a2e0f07de40f6331dd5865fb3
|
4
|
+
data.tar.gz: 47a9a999c879d9a143d48fea3275573f557e0b33615038b0b6940c7743338939
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a960f6150eb79e81fe27c12a12d8fee66297aaac03184725df45f1c95abdc0274e211564cd4095c5e64a88ee8694ee7972f071834279022f1b779be9580ba7ec
|
7
|
+
data.tar.gz: e98df2b3bb0770a0531b982002a319637821cc842be29ea832e916ffafbaf827ec1d9c275604ce13ecdcb278213d8bc9b54013981406f0d23ef95399bb552001
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -104,7 +104,10 @@ Or install it yourself as:
|
|
104
104
|
To avoid filling Redis storage with stale subscription data:
|
105
105
|
|
106
106
|
1. Set `GRAPHQL_ANYCABLE_SUBSCRIPTION_EXPIRATION_SECONDS` environment variable to number of seconds (e.g. `604800` for 1 week). See [anyway_config] documentation to other ways of configuring this gem.
|
107
|
-
|
107
|
+
|
108
|
+
2. Execute `rake graphql:anycable:clean` once in a while to clean up stale subscription data.
|
109
|
+
|
110
|
+
Heroku users should set up `GRAPHQL_ANYCABLE_USE_REDIS_OBJECT_ON_CLEANUP` environment variable to `false` due to [limitations in Heroku Redis](https://devcenter.heroku.com/articles/heroku-redis#connection-permissions).
|
108
111
|
|
109
112
|
## Development
|
110
113
|
|
data/graphql-anycable.gemspec
CHANGED
@@ -26,12 +26,12 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
|
-
spec.add_dependency "anycable", "
|
30
|
-
spec.add_dependency "anyway_config", "
|
29
|
+
spec.add_dependency "anycable", ">= 0.6.0", "< 2"
|
30
|
+
spec.add_dependency "anyway_config", ">= 1.3", "< 3"
|
31
31
|
spec.add_dependency "graphql", "~> 1.8"
|
32
32
|
|
33
|
-
spec.add_development_dependency "bundler", "~>
|
33
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
34
34
|
spec.add_development_dependency "fakeredis"
|
35
|
-
spec.add_development_dependency "rake", "
|
35
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
36
36
|
spec.add_development_dependency "rspec", "~> 3.0"
|
37
37
|
end
|
@@ -4,39 +4,61 @@ require "graphql-anycable"
|
|
4
4
|
|
5
5
|
namespace :graphql do
|
6
6
|
namespace :anycable do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
desc "Clean up stale graphql channels, subscriptions, and events from redis"
|
8
|
+
task clean: %i[clean:channels clean:subscriptions clean:events]
|
9
|
+
|
10
|
+
# Old name that was used earlier
|
11
|
+
task clean_expired_subscriptions: :clean
|
12
|
+
|
13
|
+
namespace :clean do
|
14
|
+
KLASS = GraphQL::Subscriptions::AnyCableSubscriptions
|
15
|
+
|
16
|
+
# Clean up old channels
|
17
|
+
task :channels do
|
18
|
+
next unless config.subscription_expiration_seconds
|
19
|
+
next unless config.use_redis_object_on_cleanup
|
13
20
|
|
14
|
-
|
15
|
-
|
21
|
+
redis.scan_each(match: "#{KLASS::CHANNEL_PREFIX}*") do |key|
|
22
|
+
idle = redis.object("IDLETIME", key)
|
23
|
+
next if idle&.<= config.subscription_expiration_seconds
|
16
24
|
|
17
|
-
|
18
|
-
|
19
|
-
idle = redis.object("IDLETIME", key)
|
20
|
-
next if idle&.<= config.subscription_expiration_seconds
|
21
|
-
redis.del(key)
|
25
|
+
redis.del(key)
|
26
|
+
end
|
22
27
|
end
|
23
28
|
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
next
|
28
|
-
|
29
|
+
# Clean up old subscriptions (they should have expired by themselves)
|
30
|
+
task :subscriptions do
|
31
|
+
next unless config.subscription_expiration_seconds
|
32
|
+
next unless config.use_redis_object_on_cleanup
|
33
|
+
|
34
|
+
redis.scan_each(match: "#{KLASS::SUBSCRIPTION_PREFIX}*") do |key|
|
35
|
+
idle = redis.object("IDLETIME", key)
|
36
|
+
next if idle&.<= config.subscription_expiration_seconds
|
37
|
+
|
38
|
+
redis.del(key)
|
39
|
+
end
|
29
40
|
end
|
30
41
|
|
31
|
-
#
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
42
|
+
# Clean up subscription_ids from events for expired subscriptions
|
43
|
+
task :events do
|
44
|
+
redis.scan_each(match: "#{KLASS::SUBSCRIPTION_EVENTS_PREFIX}*") do |key|
|
45
|
+
subscription_id = key.sub(/\A#{KLASS::SUBSCRIPTION_EVENTS_PREFIX}/, "")
|
46
|
+
next if redis.exists(KLASS::SUBSCRIPTION_PREFIX + subscription_id)
|
47
|
+
|
48
|
+
redis.smembers(key).each do |event_topic|
|
49
|
+
redis.srem(KLASS::EVENT_PREFIX + event_topic, subscription_id)
|
50
|
+
end
|
51
|
+
redis.del(key)
|
37
52
|
end
|
38
|
-
redis.del(key)
|
39
53
|
end
|
40
54
|
end
|
55
|
+
|
56
|
+
def config
|
57
|
+
@config ||= GraphQL::Anycable::Config.new
|
58
|
+
end
|
59
|
+
|
60
|
+
def redis
|
61
|
+
GraphQL::Anycable.redis
|
62
|
+
end
|
41
63
|
end
|
42
64
|
end
|
metadata
CHANGED
@@ -1,43 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-anycable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Novikov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: anycable
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.6.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 0.6.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: anyway_config
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
39
|
version: '1.3'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '3'
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
38
|
-
- - "
|
47
|
+
- - ">="
|
39
48
|
- !ruby/object:Gem::Version
|
40
49
|
version: '1.3'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '3'
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: graphql
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +70,14 @@ dependencies:
|
|
58
70
|
requirements:
|
59
71
|
- - "~>"
|
60
72
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
73
|
+
version: '2.0'
|
62
74
|
type: :development
|
63
75
|
prerelease: false
|
64
76
|
version_requirements: !ruby/object:Gem::Requirement
|
65
77
|
requirements:
|
66
78
|
- - "~>"
|
67
79
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
80
|
+
version: '2.0'
|
69
81
|
- !ruby/object:Gem::Dependency
|
70
82
|
name: fakeredis
|
71
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,16 +96,16 @@ dependencies:
|
|
84
96
|
name: rake
|
85
97
|
requirement: !ruby/object:Gem::Requirement
|
86
98
|
requirements:
|
87
|
-
- - "
|
99
|
+
- - ">="
|
88
100
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
101
|
+
version: 12.3.3
|
90
102
|
type: :development
|
91
103
|
prerelease: false
|
92
104
|
version_requirements: !ruby/object:Gem::Requirement
|
93
105
|
requirements:
|
94
|
-
- - "
|
106
|
+
- - ">="
|
95
107
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
108
|
+
version: 12.3.3
|
97
109
|
- !ruby/object:Gem::Dependency
|
98
110
|
name: rspec
|
99
111
|
requirement: !ruby/object:Gem::Requirement
|