celluloid_pubsub_redis_adapter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +26 -0
- data/.coveralls.yml +2 -0
- data/.gitignore +19 -0
- data/.reek +11 -0
- data/.rspec +1 -0
- data/.rubocop.yml +72 -0
- data/.travis.yml +16 -0
- data/CONTRIBUTING.md +44 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +158 -0
- data/LICENSE +20 -0
- data/README.md +135 -0
- data/Rakefile +35 -0
- data/celluloid_pubsub_redis_adapter.gemspec +32 -0
- data/examples/log/celluloid_pubsub.log +43 -0
- data/examples/redis_test.rb +2 -0
- data/examples/shared_classes.rb +73 -0
- data/examples/simple_test.rb +2 -0
- data/init.rb +1 -0
- data/lib/celluloid_pubsub_redis_adapter/redis_reactor.rb +282 -0
- data/lib/celluloid_pubsub_redis_adapter/version.rb +27 -0
- data/lib/celluloid_pubsub_redis_adapter.rb +2 -0
- data/spec/lib/celluloid_pubsub/reactor_spec.rb +221 -0
- data/spec/spec_helper.rb +47 -0
- metadata +312 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 11d06e85aea9cb87b76a68afc1afbe9e0a32d413
|
4
|
+
data.tar.gz: 31e6c1392ac24cd63779185e02faa565effe3bd1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4e42edfdfff33458b40f171bf7062892b518983e06263837d8cc910e092451b078ce14202c6f6e7472914b400b8b4a5c4981499b87c126f3624bae3931240d8e
|
7
|
+
data.tar.gz: 06e6ee43603736acaaf254d4c03246e41b94e98f05ec02721041860fbd8bd94a144f98beaf552db4593c345ab58cec07bec2a87c23220c6f1dc74773c89f2673
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
---
|
2
|
+
engines:
|
3
|
+
bundler-audit:
|
4
|
+
enabled: false
|
5
|
+
csslint:
|
6
|
+
enabled: false
|
7
|
+
eslint:
|
8
|
+
enabled: false
|
9
|
+
fixme:
|
10
|
+
enabled: true
|
11
|
+
rubocop:
|
12
|
+
enabled: true
|
13
|
+
ratings:
|
14
|
+
paths:
|
15
|
+
- Gemfile.lock
|
16
|
+
- "**.css"
|
17
|
+
- "**.js"
|
18
|
+
- "**.jsx"
|
19
|
+
- "**.rb"
|
20
|
+
exclude_paths:
|
21
|
+
- spec/**/*
|
22
|
+
- examples/**/*
|
23
|
+
- test/**/*
|
24
|
+
- vendor/**/*
|
25
|
+
- bin/**/*
|
26
|
+
- .codeclimate.yml
|
data/.coveralls.yml
ADDED
data/.gitignore
ADDED
data/.reek
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- washout_builder.gemspec
|
4
|
+
- bin/**/*
|
5
|
+
- Guardfile
|
6
|
+
- vendor/**/*
|
7
|
+
- examples/**/*
|
8
|
+
|
9
|
+
ClassLength:
|
10
|
+
Max: 500
|
11
|
+
|
12
|
+
Documentation:
|
13
|
+
Enabled: true
|
14
|
+
|
15
|
+
Encoding:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
LineLength:
|
19
|
+
Max: 200
|
20
|
+
|
21
|
+
AccessModifierIndentation:
|
22
|
+
EnforcedStyle: outdent
|
23
|
+
|
24
|
+
IfUnlessModifier:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
CaseIndentation:
|
28
|
+
IndentWhenRelativeTo: case
|
29
|
+
IndentOneStep: true
|
30
|
+
|
31
|
+
MethodLength:
|
32
|
+
CountComments: false
|
33
|
+
Max: 20
|
34
|
+
|
35
|
+
SignalException:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
ColonMethodCall:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
AsciiComments:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
RegexpLiteral:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
AssignmentInCondition:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
ParameterLists:
|
51
|
+
CountKeywordArgs: false
|
52
|
+
|
53
|
+
SingleLineBlockParams:
|
54
|
+
Methods:
|
55
|
+
- reduce:
|
56
|
+
- memo
|
57
|
+
- item
|
58
|
+
|
59
|
+
Metrics/AbcSize:
|
60
|
+
Enabled: false
|
61
|
+
|
62
|
+
Style/CollectionMethods:
|
63
|
+
Enabled: true
|
64
|
+
|
65
|
+
Style/SymbolArray:
|
66
|
+
Enabled: true
|
67
|
+
|
68
|
+
Style/ExtraSpacing:
|
69
|
+
Enabled: true
|
70
|
+
|
71
|
+
Style/FileName:
|
72
|
+
Enabled: false
|
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
sudo: false
|
2
|
+
cache: bundler
|
3
|
+
language: ruby
|
4
|
+
before_install:
|
5
|
+
- "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
|
6
|
+
- gem install bundler
|
7
|
+
rvm:
|
8
|
+
- 1.9.3
|
9
|
+
- 2.0.0
|
10
|
+
- 2.1.5
|
11
|
+
- 2.2.2
|
12
|
+
- 2.2.3
|
13
|
+
env:
|
14
|
+
- RAILS_ENV=test RACK_ENV=test
|
15
|
+
notifications:
|
16
|
+
email: false
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
We love pull requests. Here's a quick guide.
|
4
|
+
|
5
|
+
Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
6
|
+
|
7
|
+
Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
8
|
+
|
9
|
+
Fork, then clone the repo:
|
10
|
+
|
11
|
+
git clone git@github.com:your-username/celluloid_pubsub.git
|
12
|
+
|
13
|
+
Start a feature/bugfix branch.
|
14
|
+
|
15
|
+
Set up your machine:
|
16
|
+
|
17
|
+
bundle install
|
18
|
+
|
19
|
+
Make sure the tests pass:
|
20
|
+
|
21
|
+
bundle exec rake
|
22
|
+
|
23
|
+
Make your change. Add tests for your change. Make the tests pass:
|
24
|
+
|
25
|
+
bundle exec rake
|
26
|
+
|
27
|
+
Push to your fork and [submit a pull request][pr].
|
28
|
+
|
29
|
+
[pr]: https://github.com/bogdanRada/celluloid_pubsub/compare
|
30
|
+
|
31
|
+
At this point you're waiting on us. We like to at least comment on pull requests
|
32
|
+
within three business days (and, typically, one business day). We may suggest
|
33
|
+
some changes or improvements or alternatives.
|
34
|
+
|
35
|
+
Some things that will increase the chance that your pull request is accepted:
|
36
|
+
|
37
|
+
* Write tests.
|
38
|
+
* Try to follow this [style guide][style].
|
39
|
+
* Write a [good commit message][commit].
|
40
|
+
|
41
|
+
[style]: https://github.com/thoughtbot/guides/tree/master/style
|
42
|
+
[commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
43
|
+
|
44
|
+
Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
celluloid_pubsub_redis_adapter (0.0.1)
|
5
|
+
celluloid_pubsub (~> 0.6, >= 0.6)
|
6
|
+
em-hiredis (~> 0.3, >= 0.3.0)
|
7
|
+
|
8
|
+
PATH
|
9
|
+
remote: /home/raul/workspace/github/bogdanRada/celluloid_pubsub
|
10
|
+
specs:
|
11
|
+
celluloid_pubsub (0.6.0)
|
12
|
+
activesupport (~> 4.1, >= 4.1.0)
|
13
|
+
celluloid (~> 0.16.0, ~> 0.16)
|
14
|
+
celluloid-io (~> 0.16, >= 0.16.2)
|
15
|
+
celluloid-websocket-client (~> 0.0, >= 0.0.1)
|
16
|
+
http (~> 1.0, >= 1.0.2)
|
17
|
+
json (~> 1.8, >= 1.8.3)
|
18
|
+
reel (~> 0.6, >= 0.6.0)
|
19
|
+
|
20
|
+
GEM
|
21
|
+
remote: http://rubygems.org/
|
22
|
+
specs:
|
23
|
+
activesupport (4.2.5.1)
|
24
|
+
i18n (~> 0.7)
|
25
|
+
json (~> 1.7, >= 1.7.7)
|
26
|
+
minitest (~> 5.1)
|
27
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
28
|
+
tzinfo (~> 1.1)
|
29
|
+
addressable (2.4.0)
|
30
|
+
celluloid (0.16.0)
|
31
|
+
timers (~> 4.0.0)
|
32
|
+
celluloid-io (0.16.2)
|
33
|
+
celluloid (>= 0.16.0)
|
34
|
+
nio4r (>= 1.1.0)
|
35
|
+
celluloid-websocket-client (0.0.2)
|
36
|
+
celluloid-io
|
37
|
+
websocket-driver
|
38
|
+
coderay (1.1.0)
|
39
|
+
colored (1.2)
|
40
|
+
coveralls (0.8.10)
|
41
|
+
json (~> 1.8)
|
42
|
+
rest-client (>= 1.6.8, < 2)
|
43
|
+
simplecov (~> 0.11.0)
|
44
|
+
term-ansicolor (~> 1.3)
|
45
|
+
thor (~> 0.19.1)
|
46
|
+
tins (~> 1.6.0)
|
47
|
+
diff-lcs (1.2.5)
|
48
|
+
docile (1.1.5)
|
49
|
+
domain_name (0.5.20160128)
|
50
|
+
unf (>= 0.0.5, < 1.0.0)
|
51
|
+
em-hiredis (0.3.1)
|
52
|
+
eventmachine (~> 1.0)
|
53
|
+
hiredis (~> 0.6.0)
|
54
|
+
eventmachine (1.0.9.1)
|
55
|
+
github-markup (1.4.0)
|
56
|
+
hiredis (0.6.1)
|
57
|
+
hitimes (1.2.3)
|
58
|
+
http (1.0.2)
|
59
|
+
addressable (~> 2.3)
|
60
|
+
http-cookie (~> 1.0)
|
61
|
+
http-form_data (~> 1.0.1)
|
62
|
+
http_parser.rb (~> 0.6.0)
|
63
|
+
http-cookie (1.0.2)
|
64
|
+
domain_name (~> 0.5)
|
65
|
+
http-form_data (1.0.1)
|
66
|
+
http_parser.rb (0.6.0)
|
67
|
+
i18n (0.7.0)
|
68
|
+
inch (0.7.0)
|
69
|
+
pry
|
70
|
+
sparkr (>= 0.2.0)
|
71
|
+
term-ansicolor
|
72
|
+
yard (~> 0.8.7.5)
|
73
|
+
json (1.8.3)
|
74
|
+
metaclass (0.0.4)
|
75
|
+
method_source (0.8.2)
|
76
|
+
mime-types (2.99)
|
77
|
+
minitest (5.8.4)
|
78
|
+
mocha (1.1.0)
|
79
|
+
metaclass (~> 0.0.1)
|
80
|
+
netrc (0.11.0)
|
81
|
+
nio4r (1.2.1)
|
82
|
+
pry (0.10.3)
|
83
|
+
coderay (~> 1.1.0)
|
84
|
+
method_source (~> 0.8.1)
|
85
|
+
slop (~> 3.4)
|
86
|
+
rack (1.6.4)
|
87
|
+
rake (10.5.0)
|
88
|
+
redcarpet (3.3.4)
|
89
|
+
reel (0.6.0)
|
90
|
+
celluloid (>= 0.15.1)
|
91
|
+
celluloid-io (>= 0.15.0)
|
92
|
+
http (>= 0.6.0.pre)
|
93
|
+
http_parser.rb (>= 0.6.0)
|
94
|
+
rack
|
95
|
+
websocket-driver (>= 0.5.1)
|
96
|
+
rest-client (1.8.0)
|
97
|
+
http-cookie (>= 1.0.2, < 2.0)
|
98
|
+
mime-types (>= 1.16, < 3.0)
|
99
|
+
netrc (~> 0.7)
|
100
|
+
rspec (3.4.0)
|
101
|
+
rspec-core (~> 3.4.0)
|
102
|
+
rspec-expectations (~> 3.4.0)
|
103
|
+
rspec-mocks (~> 3.4.0)
|
104
|
+
rspec-core (3.4.2)
|
105
|
+
rspec-support (~> 3.4.0)
|
106
|
+
rspec-expectations (3.4.0)
|
107
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
108
|
+
rspec-support (~> 3.4.0)
|
109
|
+
rspec-mocks (3.4.1)
|
110
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
111
|
+
rspec-support (~> 3.4.0)
|
112
|
+
rspec-support (3.4.1)
|
113
|
+
simplecov (0.11.2)
|
114
|
+
docile (~> 1.1.0)
|
115
|
+
json (~> 1.8)
|
116
|
+
simplecov-html (~> 0.10.0)
|
117
|
+
simplecov-html (0.10.0)
|
118
|
+
simplecov-summary (0.0.4)
|
119
|
+
colored
|
120
|
+
simplecov
|
121
|
+
slop (3.6.0)
|
122
|
+
sparkr (0.4.1)
|
123
|
+
term-ansicolor (1.3.2)
|
124
|
+
tins (~> 1.0)
|
125
|
+
thor (0.19.1)
|
126
|
+
thread_safe (0.3.5)
|
127
|
+
timers (4.0.4)
|
128
|
+
hitimes
|
129
|
+
tins (1.6.0)
|
130
|
+
tzinfo (1.2.2)
|
131
|
+
thread_safe (~> 0.1)
|
132
|
+
unf (0.1.4)
|
133
|
+
unf_ext
|
134
|
+
unf_ext (0.0.7.2)
|
135
|
+
websocket-driver (0.6.3)
|
136
|
+
websocket-extensions (>= 0.1.0)
|
137
|
+
websocket-extensions (0.1.2)
|
138
|
+
yard (0.8.7.6)
|
139
|
+
|
140
|
+
PLATFORMS
|
141
|
+
ruby
|
142
|
+
|
143
|
+
DEPENDENCIES
|
144
|
+
celluloid_pubsub!
|
145
|
+
celluloid_pubsub_redis_adapter!
|
146
|
+
coveralls (~> 0.7, >= 0.7)
|
147
|
+
github-markup (~> 1.3, >= 1.3.3)
|
148
|
+
inch (~> 0.6, >= 0.6)
|
149
|
+
mocha (~> 1.1, >= 1.1)
|
150
|
+
rake (~> 10.5, >= 10.5)
|
151
|
+
redcarpet (~> 3.3, >= 3.3)
|
152
|
+
rspec (~> 3.4, >= 3.4)
|
153
|
+
simplecov (~> 0.10, >= 0.10)
|
154
|
+
simplecov-summary (~> 0.0.4, >= 0.0.4)
|
155
|
+
yard (~> 0.8, >= 0.8.7)
|
156
|
+
|
157
|
+
BUNDLED WITH
|
158
|
+
1.11.2
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2016 bogdanRada
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
celluloid_pubsub_redis_adapter
|
2
|
+
==============================
|
3
|
+
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/celluloid_pubsub.svg)](http://badge.fury.io/rb/celluloid_pubsub) [![Gem Downloads](https://ruby-gem-downloads-badge.herokuapp.com/celluloid_pubsub_redis_adapter?type=total&style=dynamic)](https://github.com/bogdanRada/celluloid_pubsub_redis_adapter) [![Analytics](https://ga-beacon.appspot.com/UA-72570203-1/bogdanRada/celluloid_pubsub_redis_adapter)](https://github.com/bogdanRada/celluloid_pubsub_redis_adapter)
|
5
|
+
|
6
|
+
Description
|
7
|
+
-----------
|
8
|
+
|
9
|
+
CelluloidPubsubRedisAdapter is a simple ruby implementation of publish subscribe design patterns using celluloid actors and websockets, using Celluloid::Reel server and redis as a publish subscribe backend
|
10
|
+
|
11
|
+
Requirements
|
12
|
+
------------
|
13
|
+
|
14
|
+
1. [Ruby 1.9.x or Ruby 2.x.x](http://www.ruby-lang.org)
|
15
|
+
2. [celluloid_pubsub >= 0.6.0](https://github.com/bogdanRada/celluloid_pubub)
|
16
|
+
3. [em-hiredis >= 0.3.0](https://github.com/mloughran/em-hiredis)
|
17
|
+
|
18
|
+
Compatibility
|
19
|
+
-------------
|
20
|
+
|
21
|
+
Rails >3.0 only. MRI 1.9.x, 2.x, JRuby (--1.9).
|
22
|
+
|
23
|
+
Ruby 1.8 is not officially supported. We will accept further compatibilty pull-requests but no upcoming versions will be tested against it.
|
24
|
+
|
25
|
+
Rubinius support temporarily dropped due to Rails 4 incompatibility.
|
26
|
+
|
27
|
+
Installation Instructions
|
28
|
+
-------------------------
|
29
|
+
|
30
|
+
Add the following to your Gemfile:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
gem "celluloid_pubsub_redis_adapter"
|
34
|
+
```
|
35
|
+
|
36
|
+
Please read [Release Details](https://github.com/bogdanRada/celluloid_pubsub_redis_adapter/releases) if you are upgrading. We break backward compatibility between large ticks but you can expect it to be specified at release notes.
|
37
|
+
|
38
|
+
Usage
|
39
|
+
-----
|
40
|
+
|
41
|
+
Creating a websocket server is simple as doing this. This are all the options available with their default values.
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
CelluloidPubsub::WebServer.supervise_as(:web_server,
|
45
|
+
enable_debug: true, # if debug messages should be logged
|
46
|
+
adapter: 'redis' , # if set to 'redis', will instantiate a RedisReactor class to handle each connection, which requires Redis to be available. Otherwise will use a simple Reactor to handle the connections which has no dependencies .
|
47
|
+
log_file_path: "path/to/log_file.log", # The log file where all debugging information will be printed
|
48
|
+
hostname: "0.0.0.0", # the hostname of the server.
|
49
|
+
port: 1234, # the port on which the server will listen for connections
|
50
|
+
path: '/ws', # the relative path used in the URL where connections are allowed to connect
|
51
|
+
spy: false, # whether to spy all internal Websocket connections in order to get more debugging information
|
52
|
+
backlog: 1024 # the number of connections allowed to be connected to the server at a certain time
|
53
|
+
)
|
54
|
+
```
|
55
|
+
|
56
|
+
Creating a client is simple as doing this. If you provide the channel when you initialize the **CelluloidPubsub::Client** it will automatically start the subscription to that channel. But sometimes, you might want to subscribe at a later time, so you can just omit the channel when you initialize the client, and use instead **@client.subscribe('test_channel')**. After the subscription has started, the client must implement the method **on_message** and the **on_close** method (called when client disconnects from the channel). The method **on_message** will receive all incoming messages from the server. You can test if the subscription was successful by doing this **@client.succesfull_subscription?(message)**.
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
class MyAwesomeClient
|
60
|
+
include Celluloid
|
61
|
+
include Celluloid::Logger
|
62
|
+
|
63
|
+
def initialize(options = {})
|
64
|
+
@client = CelluloidPubsub::Client.new({
|
65
|
+
actor: Actor.current,
|
66
|
+
channel: 'test_channel', # the channel to which this client will subscribe to.
|
67
|
+
log_file_path: "path/to/log_file.log", # The log file where all debugging information will be printed
|
68
|
+
hostname: "0.0.0.0", # the hostname of the server.
|
69
|
+
port: 1234,# the port on which the connection will be made to
|
70
|
+
path: '/ws', # the relative path used in the URL where the connection will be connecting to
|
71
|
+
enable_debug: false # if debug messages should be logged
|
72
|
+
}.merge(options))
|
73
|
+
end
|
74
|
+
|
75
|
+
def on_message(message)
|
76
|
+
if @client.succesfull_subscription?(message)
|
77
|
+
puts "subscriber got successful subscription #{message.inspect}"
|
78
|
+
@client.publish('test_channel2', 'data' => ' subscriber got successfull subscription') # the message needs to be a Hash
|
79
|
+
else
|
80
|
+
puts "subscriber got message #{message.inspect}"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def on_close(code, reason)
|
85
|
+
puts "websocket connection closed: #{code.inspect}, #{reason.inspect}"
|
86
|
+
terminate
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
```
|
93
|
+
|
94
|
+
The methods available that the **CelluloidPubsub::Client** instance can execute are:
|
95
|
+
|
96
|
+
- subscribe -- subscribe - accepts a string as a channel name
|
97
|
+
- publish - accepts a string as a channel name, and a Hash object
|
98
|
+
- unsubscribe - accepts a string as a channel_name from which the client will unsubscribe from
|
99
|
+
- unsubscribe_clients - accepts a string as a channel_name . This will disconnect all clients that are subscribed to that channel.
|
100
|
+
- unsubscribe_all - This does not have any parameters. Will unsubscribe all clients from all channnels
|
101
|
+
- on_close - This accepts a code and a reason as parameters. This method will be called when the client disconnects from the channel.
|
102
|
+
|
103
|
+
Examples
|
104
|
+
--------
|
105
|
+
|
106
|
+
Please check the [Examples Folder](https://github.com/bogdanRada/celluloid_pubsub_redis_adapter/tree/master/examples). There you can find some basic examples.
|
107
|
+
|
108
|
+
Testing
|
109
|
+
-------
|
110
|
+
|
111
|
+
To test, do the following:
|
112
|
+
|
113
|
+
1. cd to the gem root.
|
114
|
+
2. bundle install
|
115
|
+
3. bundle exec rake
|
116
|
+
|
117
|
+
Contributions
|
118
|
+
-------------
|
119
|
+
|
120
|
+
Please log all feedback/issues via [Github Issues](http://github.com/bogdanRada/celluloid_pubsub_redis_adapter/issues). Thanks.
|
121
|
+
|
122
|
+
Contributing to celluloid_pubsub_redis_adapter
|
123
|
+
----------------------------------------------
|
124
|
+
|
125
|
+
- Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
126
|
+
- Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
127
|
+
- Fork the project.
|
128
|
+
- Start a feature/bugfix branch.
|
129
|
+
- Commit and push until you are happy with your contribution.
|
130
|
+
- Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
131
|
+
- Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
132
|
+
|
133
|
+
== Copyright
|
134
|
+
|
135
|
+
Copyright (c) 2016 bogdanRada. See LICENSE.txt for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'coveralls/rake/task'
|
5
|
+
require 'yard'
|
6
|
+
Coveralls::RakeTask.new
|
7
|
+
|
8
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
9
|
+
spec.rspec_opts = ['--backtrace', '--fail-fast'] if ENV['DEBUG']
|
10
|
+
end
|
11
|
+
|
12
|
+
YARD::Config.options[:load_plugins] = true
|
13
|
+
YARD::Config.load_plugins
|
14
|
+
|
15
|
+
YARD::Rake::YardocTask.new do |t|
|
16
|
+
t.files = ['lib/**/*.rb', 'spec/**/*_spec.rb'] # optional
|
17
|
+
t.options = ['--any', '--extra', '--opts', '--markup-provider=redcarpet', '--markup=markdown', '--debug'] # optional
|
18
|
+
t.stats_options = ['--list-undoc'] # optional
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Default: run the unit tests.'
|
22
|
+
task default: [:all]
|
23
|
+
|
24
|
+
desc 'Test the plugin under all supported Rails versions.'
|
25
|
+
task :all do |_t|
|
26
|
+
if ENV['TRAVIS']
|
27
|
+
exec('bundle exec rake spec && bundle exec rake coveralls:push')
|
28
|
+
else
|
29
|
+
exec('bundle exec rake spec')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
task :docs do
|
34
|
+
exec('bundle exec inch --pedantic && bundle exec yard --list-undoc')
|
35
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path('../lib/celluloid_pubsub_redis_adapter/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'celluloid_pubsub_redis_adapter'
|
5
|
+
s.version = CelluloidPubsubRedisAdapter.gem_version
|
6
|
+
s.platform = Gem::Platform::RUBY
|
7
|
+
s.summary = 'Simple ruby implementation of a Redis Reactor used for publish subscribe communication between celluloid actors using Reel websocket server'
|
8
|
+
s.email = 'raoul_ice@yahoo.com'
|
9
|
+
s.homepage = 'http://github.com/bogdanRada/celluloid_pubsub/'
|
10
|
+
s.description = 'Simple ruby implementation of a Redis Reactor used for publish subscribe communication between celluloid actors using Reel websocket server'
|
11
|
+
s.authors = ['bogdanRada']
|
12
|
+
s.date = Date.today
|
13
|
+
|
14
|
+
s.licenses = ['MIT']
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = s.files.grep(/^(spec)/)
|
17
|
+
s.require_paths = ['lib']
|
18
|
+
|
19
|
+
s.add_runtime_dependency 'celluloid_pubsub', '~> 0.6', '>= 0.6'
|
20
|
+
s.add_runtime_dependency 'em-hiredis', '~> 0.3', '>= 0.3.0'
|
21
|
+
|
22
|
+
s.add_development_dependency 'rspec', '~> 3.4', '>= 3.4'
|
23
|
+
s.add_development_dependency 'simplecov', '~> 0.10', '>= 0.10'
|
24
|
+
s.add_development_dependency 'simplecov-summary', '~> 0.0.4', '>= 0.0.4'
|
25
|
+
s.add_development_dependency 'mocha', '~> 1.1', '>= 1.1'
|
26
|
+
s.add_development_dependency 'coveralls', '~> 0.7', '>= 0.7'
|
27
|
+
s.add_development_dependency 'rake', '~> 10.5', '>= 10.5'
|
28
|
+
s.add_development_dependency 'yard', '~> 0.8', '>= 0.8.7'
|
29
|
+
s.add_development_dependency 'redcarpet', '~> 3.3', '>= 3.3'
|
30
|
+
s.add_development_dependency 'github-markup', '~> 1.3', '>= 1.3.3'
|
31
|
+
s.add_development_dependency 'inch', '~> 0.6', '>= 0.6'
|
32
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
D, [2016-02-29T13:16:41.552196 #13368] DEBUG -- : CelluloidPubsub::WebServer example starting on 0.0.0.0:1234
|
2
|
+
D, [2016-02-29T13:16:41.563843 #13368] DEBUG -- : CelluloidPubsub::WebServer Received a WebSocket connection
|
3
|
+
D, [2016-02-29T13:16:41.587031 #13368] DEBUG -- : CelluloidPubsub::Reactor Streaming changes for /ws
|
4
|
+
D, [2016-02-29T13:16:41.588204 #13368] DEBUG -- : Subscriber websocket connection opened
|
5
|
+
D, [2016-02-29T13:16:41.588782 #13368] DEBUG -- : Subscriber tries to subscribe to channel test_channel
|
6
|
+
D, [2016-02-29T13:16:41.595825 #13368] DEBUG -- : CelluloidPubsub::WebServer Received a WebSocket connection
|
7
|
+
D, [2016-02-29T13:16:41.596982 #13368] DEBUG -- : Subscriber sends JSON {"client_action":"subscribe","channel":"test_channel"}
|
8
|
+
D, [2016-02-29T13:16:41.599105 #13368] DEBUG -- : CelluloidPubsub::Reactor read message {"client_action":"subscribe","channel":"test_channel"}
|
9
|
+
D, [2016-02-29T13:16:41.599452 #13368] DEBUG -- : CelluloidPubsub::Reactor finds actions for {"client_action"=>"subscribe", "channel"=>"test_channel"}
|
10
|
+
D, [2016-02-29T13:16:41.600608 #13368] DEBUG -- : CelluloidPubsub::Reactor Streaming changes for /ws
|
11
|
+
D, [2016-02-29T13:16:41.601328 #13368] DEBUG -- : Publisher websocket connection opened
|
12
|
+
D, [2016-02-29T13:16:41.601563 #13368] DEBUG -- : CelluloidPubsub::Reactor subscribed to test_channel with {"client_action"=>"subscribe", "channel"=>"test_channel"}
|
13
|
+
D, [2016-02-29T13:16:41.601705 #13368] DEBUG -- : Publisher tries to subscribe to channel test_channel2
|
14
|
+
D, [2016-02-29T13:16:41.602311 #13368] DEBUG -- : Publisher sends JSON {"client_action":"subscribe","channel":"test_channel2"}
|
15
|
+
D, [2016-02-29T13:16:41.603309 #13368] DEBUG -- : Subscriber received JSON {"client_action"=>"successful_subscription", "channel"=>"test_channel"}
|
16
|
+
D, [2016-02-29T13:16:41.603358 #13368] DEBUG -- : CelluloidPubsub::Reactor read message {"client_action":"subscribe","channel":"test_channel2"}
|
17
|
+
D, [2016-02-29T13:16:41.603803 #13368] DEBUG -- : CelluloidPubsub::Reactor finds actions for {"client_action"=>"subscribe", "channel"=>"test_channel2"}
|
18
|
+
D, [2016-02-29T13:16:41.604568 #13368] DEBUG -- : Subscriber sends JSON {"client_action":"publish","channel":"test_channel2","data":{"data":" subscriber got successfull subscription"}}
|
19
|
+
D, [2016-02-29T13:16:41.604942 #13368] DEBUG -- : CelluloidPubsub::Reactor subscribed to test_channel2 with {"client_action"=>"subscribe", "channel"=>"test_channel2"}
|
20
|
+
D, [2016-02-29T13:16:41.605523 #13368] DEBUG -- : CelluloidPubsub::Reactor read message {"client_action":"publish","channel":"test_channel2","data":{"data":" subscriber got successfull subscription"}}
|
21
|
+
D, [2016-02-29T13:16:41.605993 #13368] DEBUG -- : CelluloidPubsub::Reactor finds actions for {"client_action"=>"publish", "channel"=>"test_channel2", "data"=>{"data"=>" subscriber got successfull subscription"}}
|
22
|
+
D, [2016-02-29T13:16:41.606791 #13368] DEBUG -- : Publisher received JSON {"client_action"=>"successful_subscription", "channel"=>"test_channel2"}
|
23
|
+
D, [2016-02-29T13:16:41.607485 #13368] DEBUG -- : Publisher sends JSON {"client_action":"publish","channel":"test_channel","data":{"data":" my_message"}}
|
24
|
+
D, [2016-02-29T13:16:41.608224 #13368] DEBUG -- : CelluloidPubsub::Reactor read message {"client_action":"publish","channel":"test_channel","data":{"data":" my_message"}}
|
25
|
+
D, [2016-02-29T13:16:41.608553 #13368] DEBUG -- : Publisher received JSON {"data"=>" subscriber got successfull subscription"}
|
26
|
+
D, [2016-02-29T13:16:41.609440 #13368] DEBUG -- : CelluloidPubsub::Reactor finds actions for {"client_action"=>"publish", "channel"=>"test_channel", "data"=>{"data"=>" my_message"}}
|
27
|
+
D, [2016-02-29T13:16:41.610951 #13368] DEBUG -- : Subscriber received JSON {"data"=>" my_message"}
|
28
|
+
D, [2016-02-29T13:16:43.603956 #13368] DEBUG -- : Terminating 12 actors...
|
29
|
+
D, [2016-02-29T13:16:43.604601 #13368] DEBUG -- : CelluloidPubsub::Client tries to 'shudown'
|
30
|
+
W, [2016-02-29T13:16:43.605122 #13368] WARN -- : Terminating task: type=:call, meta={:method_name=>:run}, status=:iowait
|
31
|
+
Celluloid::TaskFiber backtrace unavailable. Please try `Celluloid.task_class = Celluloid::TaskThread` if you need backtraces here.
|
32
|
+
D, [2016-02-29T13:16:43.605375 #13368] DEBUG -- : CelluloidPubsub::WebServer tries to 'shudown'
|
33
|
+
W, [2016-02-29T13:16:43.610465 #13368] WARN -- : Terminating task: type=:call, meta={:method_name=>:run}, status=:iowait
|
34
|
+
Celluloid::TaskFiber backtrace unavailable. Please try `Celluloid.task_class = Celluloid::TaskThread` if you need backtraces here.
|
35
|
+
W, [2016-02-29T13:16:43.605516 #13368] WARN -- : Terminating task: type=:call, meta={:method_name=>:run}, status=:iowait
|
36
|
+
Celluloid::TaskFiber backtrace unavailable. Please try `Celluloid.task_class = Celluloid::TaskThread` if you need backtraces here.
|
37
|
+
D, [2016-02-29T13:16:43.606016 #13368] DEBUG -- : CelluloidPubsub::Reactor tries to 'shudown'
|
38
|
+
D, [2016-02-29T13:16:43.606142 #13368] DEBUG -- : CelluloidPubsub::Client tries to 'shudown'
|
39
|
+
D, [2016-02-29T13:16:43.605704 #13368] DEBUG -- : CelluloidPubsub::Reactor tries to 'shudown'
|
40
|
+
W, [2016-02-29T13:16:43.614788 #13368] WARN -- : Terminating task: type=:call, meta={:method_name=>:run}, status=:iowait
|
41
|
+
Celluloid::TaskFiber backtrace unavailable. Please try `Celluloid.task_class = Celluloid::TaskThread` if you need backtraces here.
|
42
|
+
W, [2016-02-29T13:16:43.613311 #13368] WARN -- : Terminating task: type=:call, meta={:method_name=>:run}, status=:iowait
|
43
|
+
Celluloid::TaskFiber backtrace unavailable. Please try `Celluloid.task_class = Celluloid::TaskThread` if you need backtraces here.
|