action_cable_subscription_adapter 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/README.md +56 -0
- data/Rakefile +2 -0
- data/action_cable_subscription_adapter.gemspec +31 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/action_cable/subscription_adapter/custom_adapter.rb +10 -0
- data/lib/action_cable_subscription_adapter.rb +27 -0
- data/lib/action_cable_subscription_adapter/version.rb +3 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b38df6d29fc33495126ec7614d44ad2b8eca70a0
|
4
|
+
data.tar.gz: dc2950a586cbf0fba78d81a5e1d93656295ca39c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8e4e5588be6327eb1fe1718f7c73ce3e0471e1c013b79fa06b046d898d22086e4c957c6fe61a448f73e842915d6e7e5d5414b0ede3b321bd3a1c23bb8ddda0ce
|
7
|
+
data.tar.gz: a7931494a08942917aeef316f4890d03cb239eb812634da2facff6bbc23c8c549fe6dd5911fae8c81305bdd454d194317dfc555bd8548415e77d95c4da2f0d87
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# ActionCableSubscriptionAdapter
|
2
|
+
|
3
|
+
Implements a configuration option that allows you to inject a custom configurable Redis client
|
4
|
+
For ActionCable to use in its SubscriptionAdapter. This is useful if you use something like Redis::Namespace
|
5
|
+
Which needs to be configured with a Redis URL and Namespace name usually coming from ENV vars. Rail's `cable.yml` is insufficient for this because it doesn't allow configuration of the Redis client.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'action_cable_subscription_adapter'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install action_cable_subscription_adapter
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Inject a custom Redis client used by the ActionCable::SubscriptionAdapter
|
26
|
+
Example:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
# config/initializers/action_cable_subscription_adapter.rb
|
30
|
+
|
31
|
+
ActionCableSubscriptionAdapter.config do |c|
|
32
|
+
c.redis_connector = MyRedisClient.new your: "options"
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
You can also pass a block that will run when the ActionCable workers are initialized:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
ActionCableSubscriptionAdapter.config do |c|
|
40
|
+
c.redis_connector = ->(subscription_adapter) {
|
41
|
+
MyRedisClient.new your: "options"
|
42
|
+
}
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
The custom Redis client needs to conform to the [Redis](https://github.com/redis/redis-rb) gem's API.
|
47
|
+
|
48
|
+
## Development
|
49
|
+
|
50
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
51
|
+
|
52
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/DiegoSalazar/action_cable_subscription_adapter.
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'action_cable_subscription_adapter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "action_cable_subscription_adapter"
|
8
|
+
spec.version = ActionCableSubscriptionAdapter::VERSION
|
9
|
+
spec.authors = ["Diego Salazar"]
|
10
|
+
spec.email = ["diego@greyrobot.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Custom Subscription adapter to inject a redis_connector for ActionCable}
|
13
|
+
spec.description = %q{Implements a SubscriptionAdapter for ActionCable which uses a configurable Redis client.}
|
14
|
+
spec.homepage = "https://github.com/DiegoSalazar/action_cable_subscription_adapter"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "action_cable_subscription_adapter"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require "action_cable/subscription_adapter/redis"
|
2
|
+
|
3
|
+
# Override ActionCable's Redis adapter to use a configurable adapter
|
4
|
+
module ActionCable::SubscriptionAdapter
|
5
|
+
class CustomAdapter < Redis
|
6
|
+
def redis_connector
|
7
|
+
ActionCableSubscriptionAdapter.redis_connector.call self
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "action_cable_subscription_adapter/version"
|
2
|
+
require "action_cable/subscription_adapter/custom_adapter.rb"
|
3
|
+
|
4
|
+
module ActionCableSubscriptionAdapter
|
5
|
+
# Inject a custom Redis client used by the ActionCable::SubscriptionAdapter
|
6
|
+
# Example:
|
7
|
+
#
|
8
|
+
# ActionCableSubscriptionAdapter.config do |c|
|
9
|
+
# c.redis_connector = MyRedisClient.new
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# You can also pass a block that will run when the ActionCable workers are initialized:
|
13
|
+
#
|
14
|
+
# ActionCableSubscriptionAdapter.config do |c|
|
15
|
+
# c.redis_connector = ->(subscription_adapter) { MyRedisClient.new }
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# The custom Redis client needs to conform to the Redis gem's API.
|
19
|
+
#
|
20
|
+
mattr_accessor :redis_connector
|
21
|
+
|
22
|
+
def self.config(&block)
|
23
|
+
block.call self
|
24
|
+
@redis_connector = ->(s) { @redis_connector } unless @redis_connector.respond_to? :call
|
25
|
+
self
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: action_cable_subscription_adapter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Diego Salazar
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Implements a SubscriptionAdapter for ActionCable which uses a configurable
|
42
|
+
Redis client.
|
43
|
+
email:
|
44
|
+
- diego@greyrobot.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- action_cable_subscription_adapter.gemspec
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- lib/action_cable/subscription_adapter/custom_adapter.rb
|
57
|
+
- lib/action_cable_subscription_adapter.rb
|
58
|
+
- lib/action_cable_subscription_adapter/version.rb
|
59
|
+
homepage: https://github.com/DiegoSalazar/action_cable_subscription_adapter
|
60
|
+
licenses: []
|
61
|
+
metadata:
|
62
|
+
allowed_push_host: https://rubygems.org
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.4.6
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Custom Subscription adapter to inject a redis_connector for ActionCable
|
83
|
+
test_files: []
|