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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc4ead83b0cc39fdf211c97e4664932a6125ca48b6e30ea889ab4692c075bb23
4
- data.tar.gz: 89ff31b340ed13fbe0493245556a587692f3f6211a72422c0dbee750c8e48135
3
+ metadata.gz: edc8e6edb6c4db3e415cfc47becd596ebfb48014a78832b41aca05adc6083bea
4
+ data.tar.gz: e0e2cbb70e955815ff7e405b2ff40cc83a1da2444bb6d228e2ac2fcceb06bebe
5
5
  SHA512:
6
- metadata.gz: d705c044762c1bbf2baa763ac8fcfee2a45f3bfbe0c9ec7ab8a94710af255769793eb9e2932b84edc800ee00fbcaf37ecf3b4acba1e6d475b172d5773c2b4ae0
7
- data.tar.gz: be40d20ca4ce9b35f37501646029c8bceafba7617a8d236ac66aa963f4b4f22196ea753597bfae124f357a91441ed937016766b454cc56ff649c6dbb25a40fe6
6
+ metadata.gz: 3268991586cc97001d4e0081b14d427abc16678b8c20b653fe555ac42826d3a70adf3d7a987311f45261fa9ae04a34e0d9b4288868c62028fd601033f305fded
7
+ data.tar.gz: 89f051c6c4815e116e3c0e6e796f2bcd2e4478b0cb8727f5e07bb71c358aa0452e2f32c0cff48d9853811d1d91c84e34751750de244f3083f80ca24124f7cd66
@@ -3,5 +3,7 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.5.1
7
- before_install: gem install bundler -v 1.16.4
6
+ - 2.5.3
7
+ - 2.4.5
8
+ - 2.3.8
9
+ before_install: gem install bundler -v 1.17.1
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. No expiration or data cleanup yet.
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:
@@ -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.5"
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
 
@@ -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 Graphql
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "anyway"
4
4
 
5
- module Graphql
5
+ module GraphQL
6
6
  module Anycable
7
7
  class Config < Anyway::Config
8
8
  config_name :graphql_anycable
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "rails"
4
4
 
5
- module Graphql
5
+ module GraphQL
6
6
  module Anycable
7
7
  class Railtie < ::Rails::Railtie
8
8
  rake_tasks do
@@ -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 = Graphql::Anycable::Config.new
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::PubSub.new.redis_conn
14
+ redis = GraphQL::Anycable.redis
13
15
  klass = GraphQL::Subscriptions::AnyCableSubscriptions
14
16
 
15
17
  # 1. Clean up old channels
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Graphql
4
4
  module Anycable
5
- VERSION = "0.2.0"
5
+ VERSION = "0.3.0.rc1"
6
6
  end
7
7
  end
@@ -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
- @pub_sub ||= Anycable::PubSub.new
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 ||= Graphql::Anycable::Config.new
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.2.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-09-17 00:00:00.000000000 Z
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: '0.5'
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: '0.5'
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: '0'
154
+ version: 1.3.1
155
155
  requirements: []
156
156
  rubyforge_project:
157
157
  rubygems_version: 2.7.6