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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f43d8941cd7af501d59ba278700ab982c8b7d261d4932d5ae09696533daeb9e
4
- data.tar.gz: f4e95708adc2f337356dbad4529e5d0ae6230c46919ce22d06f6b6278f5575d1
3
+ metadata.gz: 79ed158f4e882659ca963af6a22fb66ce34dfa9a2e0f07de40f6331dd5865fb3
4
+ data.tar.gz: 47a9a999c879d9a143d48fea3275573f557e0b33615038b0b6940c7743338939
5
5
  SHA512:
6
- metadata.gz: e32732357bcba4ce95912c3a81ee4b9c828049de6ec7b7f80174b173cc930ae1fa84bac1bf0259e2b1c8704e847790d6942c6b76a90c716fcf2026222a12d87b
7
- data.tar.gz: 4d8a726b1844408dcc54d66748368f14e94ff3412eea30f768f56d076a78de73e6fcee84eb20b51175784a5eb13c806c666b50c39aca01f3d1a35c26d8c23646
6
+ metadata.gz: a960f6150eb79e81fe27c12a12d8fee66297aaac03184725df45f1c95abdc0274e211564cd4095c5e64a88ee8694ee7972f071834279022f1b779be9580ba7ec
7
+ data.tar.gz: e98df2b3bb0770a0531b982002a319637821cc842be29ea832e916ffafbaf827ec1d9c275604ce13ecdcb278213d8bc9b54013981406f0d23ef95399bb552001
data/.travis.yml CHANGED
@@ -3,7 +3,8 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.5.3
7
- - 2.4.5
8
- - 2.3.8
9
- before_install: gem install bundler -v 1.17.1
6
+ - 2.7.0
7
+ - 2.6.5
8
+ - 2.5.7
9
+ - 2.4.9
10
+ before_install: gem install bundler -v "~> 2.0"
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
- 2. Execute `rake graphql:anycable:clean_expired_subscriptions` once in a while to clean up stale subscription data
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
 
@@ -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", "~> 0.6.0"
30
- spec.add_dependency "anyway_config", "~> 1.3"
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", "~> 1.16"
33
+ spec.add_development_dependency "bundler", "~> 2.0"
34
34
  spec.add_development_dependency "fakeredis"
35
- spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rake", ">= 12.3.3"
36
36
  spec.add_development_dependency "rspec", "~> 3.0"
37
37
  end
@@ -9,6 +9,7 @@ module GraphQL
9
9
  env_prefix :graphql_anycable
10
10
 
11
11
  attr_config subscription_expiration_seconds: nil
12
+ attr_config use_redis_object_on_cleanup: true
12
13
  end
13
14
  end
14
15
  end
@@ -4,39 +4,61 @@ require "graphql-anycable"
4
4
 
5
5
  namespace :graphql do
6
6
  namespace :anycable do
7
- task :clean_expired_subscriptions do
8
- config = GraphQL::Anycable::Config.new
9
- unless config.subscription_expiration_seconds
10
- warn "GraphQL::Anycable: No expiration set for subscriptions!"
11
- next
12
- end
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
- redis = GraphQL::Anycable.redis
15
- klass = GraphQL::Subscriptions::AnyCableSubscriptions
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
- # 1. Clean up old channels
18
- redis.scan_each(match: "#{klass::CHANNEL_PREFIX}*") do |key|
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
- # 2. Clean up old subscriptions (they should have expired by themselves)
25
- redis.scan_each(match: "#{klass::SUBSCRIPTION_PREFIX}*") do |key|
26
- idle = redis.object("IDLETIME", key)
27
- next if idle&.<= config.subscription_expiration_seconds
28
- redis.del(key)
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
- # 3. Clean up subscription_ids from events for expired subscriptions
32
- redis.scan_each(match: "#{klass::SUBSCRIPTION_EVENTS_PREFIX}*") do |key|
33
- subscription_id = key.sub(/\A#{klass::SUBSCRIPTION_EVENTS_PREFIX}/, "")
34
- next if redis.exists(klass::SUBSCRIPTION_PREFIX + subscription_id)
35
- redis.smembers(key).each do |event_topic|
36
- redis.srem(klass::EVENT_PREFIX + event_topic, subscription_id)
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module Anycable
5
- VERSION = "0.3.1"
5
+ VERSION = "0.3.2"
6
6
  end
7
7
  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.1
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: 2019-06-13 00:00:00.000000000 Z
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: '1.16'
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: '1.16'
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: '10.0'
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: '10.0'
108
+ version: 12.3.3
97
109
  - !ruby/object:Gem::Dependency
98
110
  name: rspec
99
111
  requirement: !ruby/object:Gem::Requirement