celluloid_pubsub 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celluloid_pubsub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada
@@ -190,46 +190,6 @@ dependencies:
190
190
  - - ">="
191
191
  - !ruby/object:Gem::Version
192
192
  version: '3.3'
193
- - !ruby/object:Gem::Dependency
194
- name: guard
195
- requirement: !ruby/object:Gem::Requirement
196
- requirements:
197
- - - "~>"
198
- - !ruby/object:Gem::Version
199
- version: '2.13'
200
- - - ">="
201
- - !ruby/object:Gem::Version
202
- version: '2.13'
203
- type: :development
204
- prerelease: false
205
- version_requirements: !ruby/object:Gem::Requirement
206
- requirements:
207
- - - "~>"
208
- - !ruby/object:Gem::Version
209
- version: '2.13'
210
- - - ">="
211
- - !ruby/object:Gem::Version
212
- version: '2.13'
213
- - !ruby/object:Gem::Dependency
214
- name: guard-rspec
215
- requirement: !ruby/object:Gem::Requirement
216
- requirements:
217
- - - "~>"
218
- - !ruby/object:Gem::Version
219
- version: '4.6'
220
- - - ">="
221
- - !ruby/object:Gem::Version
222
- version: '4.6'
223
- type: :development
224
- prerelease: false
225
- version_requirements: !ruby/object:Gem::Requirement
226
- requirements:
227
- - - "~>"
228
- - !ruby/object:Gem::Version
229
- version: '4.6'
230
- - - ">="
231
- - !ruby/object:Gem::Version
232
- version: '4.6'
233
193
  - !ruby/object:Gem::Dependency
234
194
  name: simplecov
235
195
  requirement: !ruby/object:Gem::Requirement
@@ -310,26 +270,6 @@ dependencies:
310
270
  - - ">="
311
271
  - !ruby/object:Gem::Version
312
272
  version: '0.7'
313
- - !ruby/object:Gem::Dependency
314
- name: rvm-tester
315
- requirement: !ruby/object:Gem::Requirement
316
- requirements:
317
- - - "~>"
318
- - !ruby/object:Gem::Version
319
- version: '1.1'
320
- - - ">="
321
- - !ruby/object:Gem::Version
322
- version: '1.1'
323
- type: :development
324
- prerelease: false
325
- version_requirements: !ruby/object:Gem::Requirement
326
- requirements:
327
- - - "~>"
328
- - !ruby/object:Gem::Version
329
- version: '1.1'
330
- - - ">="
331
- - !ruby/object:Gem::Version
332
- version: '1.1'
333
273
  - !ruby/object:Gem::Dependency
334
274
  name: rubocop
335
275
  requirement: !ruby/object:Gem::Requirement
@@ -351,25 +291,25 @@ dependencies:
351
291
  - !ruby/object:Gem::Version
352
292
  version: '0.33'
353
293
  - !ruby/object:Gem::Dependency
354
- name: phare
294
+ name: reek
355
295
  requirement: !ruby/object:Gem::Requirement
356
296
  requirements:
357
297
  - - "~>"
358
298
  - !ruby/object:Gem::Version
359
- version: '0.7'
299
+ version: '3.8'
360
300
  - - ">="
361
301
  - !ruby/object:Gem::Version
362
- version: '0.7'
302
+ version: 3.8.1
363
303
  type: :development
364
304
  prerelease: false
365
305
  version_requirements: !ruby/object:Gem::Requirement
366
306
  requirements:
367
307
  - - "~>"
368
308
  - !ruby/object:Gem::Version
369
- version: '0.7'
309
+ version: '3.8'
370
310
  - - ">="
371
311
  - !ruby/object:Gem::Version
372
- version: '0.7'
312
+ version: 3.8.1
373
313
  - !ruby/object:Gem::Dependency
374
314
  name: yard
375
315
  requirement: !ruby/object:Gem::Requirement
@@ -470,26 +410,6 @@ dependencies:
470
410
  - - ">="
471
411
  - !ruby/object:Gem::Version
472
412
  version: '0.6'
473
- - !ruby/object:Gem::Dependency
474
- name: guard-inch
475
- requirement: !ruby/object:Gem::Requirement
476
- requirements:
477
- - - "~>"
478
- - !ruby/object:Gem::Version
479
- version: '0.1'
480
- - - ">="
481
- - !ruby/object:Gem::Version
482
- version: 0.1.0
483
- type: :development
484
- prerelease: false
485
- version_requirements: !ruby/object:Gem::Requirement
486
- requirements:
487
- - - "~>"
488
- - !ruby/object:Gem::Version
489
- version: '0.1'
490
- - - ">="
491
- - !ruby/object:Gem::Version
492
- version: 0.1.0
493
413
  description: CelluloidPubsub is a simple ruby implementation of publish subscribe
494
414
  design patterns using celluloid actors and websockets, using Reel server for inter-process
495
415
  communication
@@ -500,6 +420,7 @@ extra_rdoc_files: []
500
420
  files:
501
421
  - ".coveralls.yml"
502
422
  - ".gitignore"
423
+ - ".reek"
503
424
  - ".rspec"
504
425
  - ".rubocop.yml"
505
426
  - ".travis.yml"
@@ -516,9 +437,10 @@ files:
516
437
  - init.rb
517
438
  - lib/celluloid_pubsub.rb
518
439
  - lib/celluloid_pubsub/client.rb
440
+ - lib/celluloid_pubsub/helper.rb
519
441
  - lib/celluloid_pubsub/reactor.rb
520
- - lib/celluloid_pubsub/redis.rb
521
- - lib/celluloid_pubsub/redis_reactor.rb
442
+ - lib/celluloid_pubsub/redis/redis.rb
443
+ - lib/celluloid_pubsub/redis/redis_reactor.rb
522
444
  - lib/celluloid_pubsub/registry.rb
523
445
  - lib/celluloid_pubsub/version.rb
524
446
  - lib/celluloid_pubsub/web_server.rb
@@ -1,25 +0,0 @@
1
- module CelluloidPubsub
2
- class Redis
3
- class << self
4
- @connected ||= false
5
- attr_accessor :connected, :connection
6
-
7
- alias_method :connected?, :connected
8
-
9
- def connect(_options = {})
10
- require 'eventmachine'
11
- require 'em-hiredis'
12
- EM.run do
13
- @connection = EM::Hiredis.connect
14
- @connected = true
15
- yield @connection if block_given?
16
- end
17
- EM.error_handler do |error|
18
- unless error.is_a?(Interrupt)
19
- puts error.inspect
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,78 +0,0 @@
1
- require_relative './reactor'
2
- module CelluloidPubsub
3
- class RedisReactor < CelluloidPubsub::Reactor
4
- include Celluloid
5
- include Celluloid::IO
6
- include Celluloid::Logger
7
-
8
- def unsubscribe(channel)
9
- super
10
- async.redis_action('unsubscribe', channel)
11
- end
12
-
13
- def add_subscriber_to_channel(channel, message)
14
- super
15
- async.redis_action('subscribe', channel, message)
16
- end
17
-
18
- def unsubscribe_from_channel(channel)
19
- super
20
- async.redis_action('unsubscribe', channel)
21
- end
22
-
23
-
24
- def unsubscribe_all
25
- CelluloidPubsub::Registry.channels.map do |channel|
26
- async.redis_action('unsubscribe', channel)
27
- end
28
- info 'clearing connections'
29
- shutdown
30
- end
31
-
32
- def shutdown
33
- @channels.each do |channel|
34
- redis_action('unsubscribe', channel)
35
- end
36
- super
37
- end
38
-
39
- private
40
-
41
- def redis_action(action, channel = nil, message = {})
42
- CelluloidPubsub::Redis.connect do |connection|
43
- pubsub = connection.pubsub
44
- pubsub.on(:unsubscribe) { |channel, remaining_subscriptions|
45
- debug [:unsubscribe_happened, channel, remaining_subscriptions].inspect if @server.debug_enabled?
46
- }
47
-
48
- if action == 'subscribe' && channel.present?
49
- subscription = pubsub.subscribe(channel) {|subscribed_message|
50
- @websocket << subscribed_message
51
- }
52
- subscription.callback { |reply|
53
- @websocket << message.merge('client_action' => 'successful_subscription', 'channel' => channel, 'subscriptions' => reply).to_json
54
- }
55
- subscription.errback {|reply|
56
- debug "subscription error #{reply.inspect}" if @server.debug_enabled?
57
- }
58
- else
59
- if channel.present?
60
- unsubscription = pubsub.unsubscribe(channel)
61
- unsubscription.callback {|reply|
62
- debug "unsubscription success #{reply.inspect}" if @server.debug_enabled?
63
- }
64
- unsubscription.errback {|reply|
65
- debug "unsubscription error #{reply.inspect}" if @server.debug_enabled?
66
- }
67
- else
68
- connection.unsubscribe
69
- end
70
-
71
- end
72
-
73
-
74
- end
75
- end
76
-
77
- end
78
- end