oceanex-slanger 0.7.1 → 0.7.1.5

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: 873ad2c526e6058fc9422328e63bd2b87913fe63ec17d3d6cba0b4809db514f8
4
- data.tar.gz: facd5b203fdcf1bc86df73bf079f3aec92964747e30a5909b71ef31afec0b8ad
3
+ metadata.gz: 8cb0189c2d4a320b9a58018e24cfd43e6d6e26155f8b85ea93ffd2a797e22262
4
+ data.tar.gz: faf6ff49096ab54b3b5f9b7328d2597694307a0337a8228130638b308db2f57a
5
5
  SHA512:
6
- metadata.gz: e204ea34edcfb2e7a254e9ba35dc177f5378c4df304c43801720ed011e157f7bad4ae81df838c5a2c95901d2c07423e8e3a8ccc2ffa3107d61a10074cb5fab3a
7
- data.tar.gz: 94a8da1071538d9b6620aaadc814ebbd33623a1c3f30a527e51d329c9b33668b30bc931b20e20526996ac20ff7bf50f8b074bb0000af1eb58c31d6635a065498
6
+ metadata.gz: a35a8aaf716ea4466ade705d8588d68b5a5a6e66141acd027305842f687a36595b18d70829fc0b321faf0a21b7a979bae95b68b6667d764b1819ef7625e45a3f
7
+ data.tar.gz: be92ee218d13219007403e6fda737e8b0e9512b6a2f5762fc23691e8077695cade690ec8a47c014a427336265665ffdd27f5321904e8a920d3fc451319191d69
data/README.md CHANGED
@@ -1,59 +1,24 @@
1
- # Slanger
1
+ # OceanEx Slanger
2
+ [![Gem Version](https://badge.fury.io/rb/oceanex-slanger.svg)](https://badge.fury.io/rb/oceanex-slanger) [![Build Status](https://travis-ci.com/jobleeyoui/slanger.svg?branch=master)](https://travis-ci.com/jobleeyoui/slanger)
2
3
 
3
- Though Slanger has been deprecated by its authors, it is still popular due to its scalability through kubernetes.
4
- This is the most important reason I decide to continue to maintain slanger. The maintenance will continue until future notice or better option comes out.
4
+ The OceanEx Slanger inherits from the unmaintained Slanger. The project is backed by OceanEx dev team.
5
5
 
6
- Feel free to log any issues or contribute to code base.
6
+ We will do regularly bug fixes and security updates.
7
7
 
8
- **Important! Slanger is not supposed to be included in your Gemfile. RubyGems is used as a distribution mechanism. If you include it in your app, you will likely get dependency conflicts. PRs updating dependencies for compatibility with your app will be closed. Thank you for reading and enjoy Slanger!**
8
+ We might further add more features or provide performance improvements for OceanEx Slanger. The maintenance will continue until we find better option.
9
9
 
10
- ## Typical usage
10
+ Feel free to log any issue or contribute to the code base.
11
11
 
12
- ```
13
- gem install slanger
14
- redis-server &> /dev/null &
15
-
16
- slanger --app_key 765ec374ae0a69f4ce44 --secret your-pusher-secret
17
- ```
18
-
19
- Slanger is a standalone server ruby implementation of the Pusher protocol. It
20
- is not designed to run inside a Rails or sinatra app, but it can be easily
21
- installed as a gem.
22
-
23
- Bundler has multiple purposes, one of which is useful for installation.
24
-
25
- ## About
12
+ **Important! OceanEx Slanger is not supposed to be included in your Gemfile. RubyGems is used as a distribution mechanism. If you include it in your app, you will likely get dependency conflicts.
13
+ PRs updating dependencies for compatibility with your app will be closed!**
26
14
 
27
- Slanger is an open source server implementation of the Pusher protocol written
28
- in Ruby. It is designed to scale horizontally across N nodes and to be agnostic
29
- as to which Slanger node a subscriber is connected to, i.e subscribers to the
30
- same channel are NOT required to be connected to the same Slanger node.
31
- Multiple Slanger nodes can sit behind a load balancer with no special
32
- configuration. In essence it was designed to be very easy to scale.
33
-
34
- Presence channel state is shared using Redis. Channels are lazily instantiated
35
- internally within a given Slanger node when the first subscriber connects. When
36
- a presence channel is instantiated within a Slanger node, it queries Redis for
37
- the global state across all nodes within the system for that channel, and then
38
- copies that state internally. Afterwards, when subscribers connect or
39
- disconnect the node publishes a presence message to all interested nodes, i.e.
40
- all nodes with at least one subscriber interested in the given channel.
41
-
42
- Slanger is smart enough to know if a new channel subscription belongs to the
43
- same user. It will not send presence messages to subscribers in this case. This
44
- happens when the user has multiple browser tabs open for example. Using a chat
45
- room backed by presence channels as a real example, one would not want
46
- "Barrington" to show up N times in the presence roster because Barrington
47
- has the chat room open in N browser tabs.
48
-
49
- Slanger was designed to be highly available and partition tolerant with
50
- eventual consistency, which in practise is instantaneous.
15
+ OceanEx Slanger is a standalone server ruby implementation of the Pusher protocol. It is not designed to run inside a Rails or sinatra app, but it can be easily installed as a gem.
51
16
 
52
17
  # How to use it
53
18
 
54
19
  ## Requirements
55
20
 
56
- - Ruby 2.1.2 or greater
21
+ - Ruby 2.6.3 or greater
57
22
  - Redis
58
23
 
59
24
  ## Server setup
@@ -77,19 +42,60 @@ If you want to run multiple slanger instances in a cluster, one option will be t
77
42
  A basic config can be found in the folder `examples`.
78
43
  Haproxy can be also used for SSL termination, leaving slanger to not have to deal with SSL checks and so on, making it lighter.
79
44
 
45
+ ## Installation instruction
46
+
47
+ The OceanEx Slanger depends on ruby 2.6.3 and above, please install ruby 2.6.3 first before install the OceanEx Slanger.
48
+ It could also run perfectly on the latest 2.7.1. If you want to align with the latest ruby, you might clone the source
49
+ code and compile yourself.
50
+
51
+ ### Linux(Ubuntu)
52
+
53
+ You could install the right version of ruby via rbenv
54
+
55
+ ```
56
+ sudo apt-get install rbenv
57
+ rbenv install 2.6.3
58
+ rbenv global 2.6.3
59
+ ```
60
+
61
+ Then install the OceanEx Slanger
62
+
63
+ ```
64
+ gem install oceanex-slanger
65
+ ```
66
+
67
+ ### Mac
68
+
69
+ Install the ruby version via home brew
80
70
 
81
- ## Starting the service
71
+ ```
72
+ brew install ruby
73
+ ```
82
74
 
83
- Slanger is packaged as a Rubygem. Installing the gem makes the 'slanger' executable available. The `slanger` executable takes arguments, of which two are mandatory: `--app_key` and `--secret`. These can but do not have to be the same as the credentials you use for Pusher. They are required because Slanger performs the same HMAC signing of API requests that Pusher does.
75
+ You might also install via rbenv
76
+ ```
77
+ brew install rbenv
78
+ rbenv install 2.6.3
79
+ rbenv global 2.6.3
80
+ ```
84
81
 
85
- __IMPORTANT:__ Redis must be running where Slanger expects it to be (either on localhost:6379 or somewhere else you told Slanger it would be using the option flag) or Slanger will fail silently. I haven't yet figured out how to get em-hiredis to treat an unreachable host as an error
82
+ Installation might fail when some dependent gems builds their native extension. This is due to the c compiler converts the warning to error when do so.
86
83
 
87
- ```bash
88
- $ gem install slanger
84
+ If you see installation fails due to `implicit-function-declaration`, you could try the following step to suppress the warning.
89
85
 
90
- $ redis-server &> /dev/null &
86
+ ```
87
+ gem install oceanex-slanger -- --with-cflags="-Wno-error=implicit-function-declaration"
88
+ ```
89
+
90
+ ## Start the OceanEx Slanger in local environment
91
+
92
+ Both the app key and app secret are just random string, you could choose any string. However, it is recommended to be long
93
+ enough to keep secure.
94
+
95
+ Oceanex Slanger also depends on redis service, specify the redis url when launching the OceanEx Slanger.
91
96
 
92
- $ slanger --app_key 765ec374ae0a69f4ce44 --secret your-pusher-secret
97
+ ```
98
+ slanger --app_key $APP_KEY --secret $APP_SECRET -r $REDIS_URL
93
99
  ```
94
100
 
95
101
  If all went to plan you should see the following output to STDOUT
@@ -113,31 +119,31 @@ Slanger API server listening on port 4567
113
119
  Slanger WebSocket server listening on port 8080
114
120
  ```
115
121
 
116
- ## Ubuntu upstart script
122
+ ## Start the OceanEx Slanger in Docker environment
123
+
124
+ The OceanEx Slanger supports running in docker environment and such approach is already encapsulated in the make command.
125
+ The dependent Redis docker image is also automatically downloaded and started.
117
126
 
118
- If you're using Ubuntu, you might find this upscript very helpful. The steps below will create an init script that will make slanger run at boot and restart if it fails.
119
- Open `/etc/init/slanger` and add:
127
+ For the app key and app secret, please check `docker-compose.yaml` and modify as needed.
128
+
129
+ ### Build the docker image
120
130
  ```
121
- start on started networking and runlevel [2345]
122
- stop on runlevel [016]
123
- respawn
124
- script
125
- LANG=en_US.UTF-8 /usr/local/rvm/gems/ruby-RUBY_VERISON/wrappers/slanger --app_key KEY --secret SECRET --redis_address redis://REDIS_IP:REDIS_PORT/REDIS_DB
126
- end script
131
+ make build
127
132
  ```
128
- This example assumes you're using rvm and a custom redis configuration
129
133
 
130
- Then, to start / stop the service, just do
134
+ ### Start the OceanEx slanger
131
135
  ```
132
- service slanger start
133
- service slanger stop
136
+ make up
134
137
  ```
135
138
 
139
+ ### Stop the service
140
+ ```
141
+ make down
142
+ ```
136
143
 
137
- ## Modifying your application code to use the Slanger service
138
-
139
- Once you have a Slanger instance listening for incoming connections you need to alter you application code to use the Slanger endpoint instead of Pusher. Fortunately this is very simple, unobtrusive, easily reversable, and very painless.
144
+ ## Modifying your application code to use the OceanEx Slanger service
140
145
 
146
+ Once you have a OceanEx Slanger instance listening for incoming connections you need to alter you application code to use the OceanEx Slanger endpoint instead of Pusher. Fortunately this is very simple, unobtrusive, easily reversable, and very painless.
141
147
 
142
148
  First you will need to add code to your server side component that publishes events to the Pusher HTTP REST API, usually this means telling the Pusher client to use a different host and port, e.g. consider this Ruby example
143
149
 
@@ -165,7 +171,7 @@ Of course you could proxy all requests to `ws.example.com` to port 8080 of your
165
171
 
166
172
  # Configuration Options
167
173
 
168
- Slanger supports several configuration options, which can be supplied as command line arguments at invocation. You can also supply a yaml file containing config options. If you use the config file in combination with other configuration options, the values passed on the command line will win. Allows running multiple instances with only a few differences easy.
174
+ OceanEx Slanger supports several configuration options, which can be supplied as command line arguments at invocation. You can also supply a yaml file containing config options. If you use the config file in combination with other configuration options, the values passed on the command line will win. Allows running multiple instances with only a few differences easy.
169
175
 
170
176
  ```
171
177
  -k or --app_key This is the Pusher app key you want to use. This is a required argument on command line or in optional config file
@@ -193,39 +199,28 @@ Slanger supports several configuration options, which can be supplied as command
193
199
  --pid_file The path to a file you want slanger to write it's PID to. Optional.
194
200
  ```
195
201
 
196
- # Why use Slanger instead of Pusher?
197
-
198
- There a few reasons you might want to use Slanger instead of Pusher, e.g.
199
-
200
- - You operate in a heavily regulated industry and are worried about sending data to 3rd parties, and it is an organisational requirement that you own your own infrastructure.
201
- - You might be travelling on an airplane without internet connectivity as I am right now. Airplane rides are very good times to get a lot done, unfortunately external services are also usually unreachable. Remove internet connectivity as a dependency of your development envirionment by running a local Slanger instance in development and Pusher in production.
202
- - Remove the network dependency from your test suite.
203
- - You want to extend the Pusher protocol or have some special requirement. If this applies to you, chances are you are out of luck as Pusher is unlikely to implement something to suit your special use case, and rightly so. With Slanger you are free to modify and extend its behavior anyway that suits your purpose.
204
-
205
- # Why did you write Slanger
206
-
207
- I wanted to write a non-trivial evented app. I also want to write a book on evented programming in Ruby as I feel there is scant good information available on the topic and this project is handy to show publishers.
208
-
209
- Pusher is an awesome service, very reasonably priced, and run by an awesome crew. Give them a spin on your next project.
210
-
211
- # Author
202
+ # Original Author
212
203
 
213
204
  - Stevie Graham
214
205
 
215
- # Core Team
206
+ # Original Core Team
216
207
 
217
208
  - Stevie Graham
218
209
  - Mark Burns
219
210
 
220
- # Contributors
211
+ # Original Contributors
221
212
 
222
213
  - Stevie Graham
223
214
  - Mark Burns
224
215
  - Florian Gilcher
225
216
  - Claudio Poli
226
217
 
227
- # Maintainer
228
- - joblee
218
+ # Current Core Team and Contributor
219
+ - Joblee
220
+ - Steve
221
+ - Meng
222
+ - Sniper
223
+ - Jiayu
229
224
 
230
225
 
231
- © 2020 a joblee joint.
226
+ © 2020 a OceanEx joint.
@@ -32,7 +32,7 @@ module Slanger
32
32
  EventPublisher.publish(valid_request.channels, event)
33
33
 
34
34
  status 202
35
- return Oj.dump({}, mode: :compat)
35
+ Oj.dump({}, mode: :compat)
36
36
  end
37
37
 
38
38
  post "/apps/:app_id/channels/:channel_id/events" do
@@ -42,7 +42,7 @@ module Slanger
42
42
  EventPublisher.publish(valid_request.channels, event)
43
43
 
44
44
  status 202
45
- return Oj.dump({}, mode: :compat)
45
+ Oj.dump({}, mode: :compat)
46
46
  end
47
47
 
48
48
  def valid_request
@@ -24,15 +24,17 @@ module Slanger
24
24
  end
25
25
 
26
26
  def lookup(channel_id)
27
- all.detect { |o| o.channel_id == channel_id }
27
+ all[channel_id]
28
28
  end
29
29
 
30
30
  def create(params = {})
31
- new(params).tap { |r| all << r }
31
+ new(params).tap do |channel|
32
+ all[channel.channel_id] = channel
33
+ end
32
34
  end
33
35
 
34
36
  def all
35
- @all ||= []
37
+ @all ||= {}
36
38
  end
37
39
 
38
40
  def unsubscribe(channel_id, subscription_id)
@@ -22,7 +22,7 @@ module Slanger
22
22
  begin
23
23
  send_payload nil, "pusher:error", e
24
24
  rescue EventMachine::WebSocket::WebSocketError
25
- # Raised if connecection already closed. Only seen with Thor load testing tool
25
+ # Raised if connection already closed. Only seen with Thor load testing tool
26
26
  end
27
27
  end
28
28
 
@@ -1,3 +1,3 @@
1
1
  module Slanger
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oceanex-slanger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.1.5
5
5
  platform: ruby
6
6
  authors:
7
- - joblee
7
+ - Joblee
8
+ - Steve
9
+ - Meng
10
+ - Sniper
11
+ - Jiayu
8
12
  autorequire:
9
13
  bindir: bin
10
14
  cert_chain: []
11
- date: 2020-09-11 00:00:00.000000000 Z
15
+ date: 2020-09-17 00:00:00.000000000 Z
12
16
  dependencies:
13
17
  - !ruby/object:Gem::Dependency
14
18
  name: eventmachine
@@ -100,14 +104,14 @@ dependencies:
100
104
  requirements:
101
105
  - - "~>"
102
106
  - !ruby/object:Gem::Version
103
- version: 5.2.4.4
107
+ version: 6.0.3
104
108
  type: :runtime
105
109
  prerelease: false
106
110
  version_requirements: !ruby/object:Gem::Requirement
107
111
  requirements:
108
112
  - - "~>"
109
113
  - !ruby/object:Gem::Version
110
- version: 5.2.4.4
114
+ version: 6.0.3
111
115
  - !ruby/object:Gem::Dependency
112
116
  name: sinatra
113
117
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +146,14 @@ dependencies:
142
146
  requirements:
143
147
  - - "~>"
144
148
  - !ruby/object:Gem::Version
145
- version: 1.1.6
149
+ version: 1.1.7
146
150
  type: :runtime
147
151
  prerelease: false
148
152
  version_requirements: !ruby/object:Gem::Requirement
149
153
  requirements:
150
154
  - - "~>"
151
155
  - !ruby/object:Gem::Version
152
- version: 1.1.6
156
+ version: 1.1.7
153
157
  - !ruby/object:Gem::Dependency
154
158
  name: oj
155
159
  requirement: !ruby/object:Gem::Requirement
@@ -304,7 +308,7 @@ dependencies:
304
308
  - - "~>"
305
309
  - !ruby/object:Gem::Version
306
310
  version: 13.0.1
307
- description: The oceanex slanger inherits from unmaintained project slanger and continue
311
+ description: The Oceanex Slanger inherits from unmaintained project Slanger and continue
308
312
  to provide update and fixes
309
313
  email:
310
314
  - jobleeyoui@gmail.com
@@ -349,13 +353,13 @@ files:
349
353
  - spec/unit/channel_spec.rb
350
354
  - spec/unit/request_validation_spec.rb
351
355
  - spec/unit/webhook_spec.rb
352
- homepage: https://github.com/jobleeyoui/slanger
356
+ homepage: https://github.com/OceanEx/slanger
353
357
  licenses:
354
358
  - MIT
355
359
  metadata:
356
- homepage_uri: https://github.com/jobleeyoui/slanger
357
- source_code_uri: https://github.com/jobleeyoui/slanger/archive/v0.7.0.zip
358
- changelog_uri: https://github.com/jobleeyoui/slanger/releases
360
+ homepage_uri: https://github.com/OceanEx/slanger
361
+ source_code_uri: https://github.com/OceanEx/slanger/archive/v0.7.1.4.zip
362
+ changelog_uri: https://github.com/OceanEx/slanger/releases
359
363
  post_install_message:
360
364
  rdoc_options: []
361
365
  require_paths: