graphql-anycable 0.2.0 → 0.3.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -2
- data/README.md +5 -3
- data/graphql-anycable.gemspec +1 -1
- data/lib/graphql-anycable.rb +13 -1
- data/lib/graphql/anycable/config.rb +1 -1
- data/lib/graphql/anycable/railtie.rb +1 -1
- data/lib/graphql/anycable/tasks/clean_expired_subscriptions.rake +4 -2
- data/lib/graphql/anycable/version.rb +1 -1
- data/lib/graphql/subscriptions/anycable_subscriptions.rb +6 -6
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edc8e6edb6c4db3e415cfc47becd596ebfb48014a78832b41aca05adc6083bea
|
4
|
+
data.tar.gz: e0e2cbb70e955815ff7e405b2ff40cc83a1da2444bb6d228e2ac2fcceb06bebe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3268991586cc97001d4e0081b14d427abc16678b8c20b653fe555ac42826d3a70adf3d7a987311f45261fa9ae04a34e0d9b4288868c62028fd601033f305fded
|
7
|
+
data.tar.gz: 89f051c6c4815e116e3c0e6e796f2bcd2e4478b0cb8727f5e07bb71c358aa0452e2f32c0cff48d9853811d1d91c84e34751750de244f3083f80ca24124f7cd66
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
A (mostly) drop-in replacement for default ActionCable subscriptions adapter shipped with [graphql gem] but works with [AnyCable]!
|
4
4
|
|
5
|
-
**IMPORTANT**: This gem is still in _proof of concept_ stage. It is not yet tested in production and everything may change without any notice. You have warned.
|
6
|
-
|
7
5
|
[![Gem Version](https://badge.fury.io/rb/graphql-anycable.svg)](https://badge.fury.io/rb/graphql-anycable)
|
8
6
|
|
9
7
|
<a href="https://evilmartians.com/?utm_source=graphql-anycable&utm_campaign=project_page">
|
@@ -18,7 +16,7 @@ See https://github.com/anycable/anycable-rails/issues/40 for more details and di
|
|
18
16
|
|
19
17
|
## Differences
|
20
18
|
|
21
|
-
- Subscription information is stored in Redis database configured to be used by AnyCable.
|
19
|
+
- Subscription information is stored in Redis database configured to be used by AnyCable. Expiration or data cleanup should be configured separately (see below).
|
22
20
|
- GraphQL queries for all subscriptions are re-executed in the process that triggers event (it may be web server, async jobs, rake tasks or whatever)
|
23
21
|
|
24
22
|
## Compatibility
|
@@ -26,6 +24,10 @@ See https://github.com/anycable/anycable-rails/issues/40 for more details and di
|
|
26
24
|
- Should work with ActionCable in development
|
27
25
|
- Should work without Rails via [LiteCable]
|
28
26
|
|
27
|
+
## Requirements
|
28
|
+
|
29
|
+
AnyCable must be configured with redis broadcast adapter (this is default).
|
30
|
+
|
29
31
|
## Installation
|
30
32
|
|
31
33
|
Add this line to your application's Gemfile:
|
data/graphql-anycable.gemspec
CHANGED
@@ -26,7 +26,7 @@ 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.
|
29
|
+
spec.add_dependency "anycable", "~> 0.6.0.rc1"
|
30
30
|
spec.add_dependency "anyway_config", "~> 1.3"
|
31
31
|
spec.add_dependency "graphql", "~> 1.8"
|
32
32
|
|
data/lib/graphql-anycable.rb
CHANGED
@@ -7,7 +7,19 @@ require_relative "graphql/anycable/config"
|
|
7
7
|
require_relative "graphql/anycable/railtie" if defined?(Rails)
|
8
8
|
require_relative "graphql/subscriptions/anycable_subscriptions"
|
9
9
|
|
10
|
-
module
|
10
|
+
module GraphQL
|
11
11
|
module Anycable
|
12
|
+
module_function
|
13
|
+
|
14
|
+
def redis
|
15
|
+
@redis ||= begin
|
16
|
+
adapter = ::Anycable.broadcast_adapter
|
17
|
+
unless adapter.is_a?(::AnyCable::BroadcastAdapters::Redis)
|
18
|
+
raise "Unsupported AnyCable adapter: #{adapter.class}. " \
|
19
|
+
"graphql-anycable works only with redis broadcast adapter."
|
20
|
+
end
|
21
|
+
::Anycable.broadcast_adapter.redis_conn
|
22
|
+
end
|
23
|
+
end
|
12
24
|
end
|
13
25
|
end
|
@@ -1,15 +1,17 @@
|
|
1
|
+
require "graphql-anycable"
|
2
|
+
|
1
3
|
# frozen_string_literal: true
|
2
4
|
|
3
5
|
namespace :graphql do
|
4
6
|
namespace :anycable do
|
5
7
|
task :clean_expired_subscriptions do
|
6
|
-
config =
|
8
|
+
config = GraphQL::Anycable::Config.new
|
7
9
|
unless config.subscription_expiration_seconds
|
8
10
|
warn "GraphQL::Anycable: No expiration set for subscriptions!"
|
9
11
|
next
|
10
12
|
end
|
11
13
|
|
12
|
-
redis = Anycable
|
14
|
+
redis = GraphQL::Anycable.redis
|
13
15
|
klass = GraphQL::Subscriptions::AnyCableSubscriptions
|
14
16
|
|
15
17
|
# 1. Clean up old channels
|
@@ -52,6 +52,10 @@ require "graphql/subscriptions"
|
|
52
52
|
module GraphQL
|
53
53
|
class Subscriptions
|
54
54
|
class AnyCableSubscriptions < GraphQL::Subscriptions
|
55
|
+
extend Forwardable
|
56
|
+
|
57
|
+
def_delegators :"GraphQL::Anycable", :redis
|
58
|
+
|
55
59
|
SUBSCRIPTION_PREFIX = "graphql-subscription:"
|
56
60
|
SUBSCRIPTION_EVENTS_PREFIX = "graphql-subscription-events:"
|
57
61
|
EVENT_PREFIX = "graphql-event:"
|
@@ -140,15 +144,11 @@ module GraphQL
|
|
140
144
|
private
|
141
145
|
|
142
146
|
def anycable
|
143
|
-
@
|
144
|
-
end
|
145
|
-
|
146
|
-
def redis
|
147
|
-
@redis ||= anycable.redis_conn
|
147
|
+
@anycable ||= ::Anycable.broadcast_adapter
|
148
148
|
end
|
149
149
|
|
150
150
|
def config
|
151
|
-
@config ||=
|
151
|
+
@config ||= GraphQL::Anycable::Config.new
|
152
152
|
end
|
153
153
|
end
|
154
154
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-anycable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Novikov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: anycable
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.6.0.rc1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.6.0.rc1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: anyway_config
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,9 +149,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: '0'
|
150
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
151
|
requirements:
|
152
|
-
- - "
|
152
|
+
- - ">"
|
153
153
|
- !ruby/object:Gem::Version
|
154
|
-
version:
|
154
|
+
version: 1.3.1
|
155
155
|
requirements: []
|
156
156
|
rubyforge_project:
|
157
157
|
rubygems_version: 2.7.6
|