litecable 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +14 -2
- data/README.md +1 -3
- data/Rakefile +3 -1
- data/examples/sinatra/Gemfile +2 -2
- data/examples/sinatra/Procfile +1 -1
- data/examples/sinatra/README.md +2 -0
- data/examples/sinatra/anycable +2 -4
- data/examples/sinatra/app.rb +1 -0
- data/examples/sinatra/chat.rb +1 -0
- data/examples/sinatra/config.ru +1 -0
- data/lib/lite_cable.rb +1 -0
- data/lib/lite_cable/anycable.rb +9 -3
- data/lib/lite_cable/channel.rb +1 -0
- data/lib/lite_cable/channel/base.rb +1 -0
- data/lib/lite_cable/channel/registry.rb +1 -0
- data/lib/lite_cable/channel/streams.rb +1 -0
- data/lib/lite_cable/coders.rb +1 -0
- data/lib/lite_cable/coders/json.rb +1 -0
- data/lib/lite_cable/coders/raw.rb +1 -0
- data/lib/lite_cable/config.rb +1 -0
- data/lib/lite_cable/connection.rb +1 -0
- data/lib/lite_cable/connection/authorization.rb +1 -0
- data/lib/lite_cable/connection/base.rb +1 -0
- data/lib/lite_cable/connection/identification.rb +1 -0
- data/lib/lite_cable/connection/streams.rb +1 -0
- data/lib/lite_cable/connection/subscriptions.rb +1 -0
- data/lib/lite_cable/internal.rb +1 -0
- data/lib/lite_cable/logging.rb +1 -0
- data/lib/lite_cable/server.rb +1 -0
- data/lib/lite_cable/server/client_socket.rb +1 -0
- data/lib/lite_cable/server/client_socket/base.rb +4 -1
- data/lib/lite_cable/server/client_socket/subscriptions.rb +1 -0
- data/lib/lite_cable/server/heart_beat.rb +3 -0
- data/lib/lite_cable/server/middleware.rb +1 -0
- data/lib/lite_cable/server/subscribers_map.rb +1 -0
- data/lib/lite_cable/version.rb +2 -1
- data/lib/litecable.rb +1 -0
- data/litecable.gemspec +1 -1
- metadata +16 -3
- data/examples/sinatra/bin/anycable-go +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2dd18b7f6891c88a86835759ce61d719586e020
|
4
|
+
data.tar.gz: e1068fc004544f1b95f119c496b78978f18ca631
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5a4d61b3a02f2ed4d9f708ee0fdf9882f33bead0a12dcc59a1e8256f8775094598771ae05c4e24b9533563545f3fad1a96856388c7cbac2276c0f245605af1d
|
7
|
+
data.tar.gz: 99fd11f00d738f3712c2359ef6085f24859c921afadc19fe23a88217ecbb8922e6ea97c81f279e3ed489af1e1b24d01e0b01871b886b4e27cb109d0300dcfdf4
|
data/.rubocop.yml
CHANGED
@@ -10,11 +10,17 @@ AllCops:
|
|
10
10
|
- 'tmp/**/*'
|
11
11
|
- 'bench/**/*'
|
12
12
|
- 'lib/anycable/rpc/**/*'
|
13
|
+
- 'vendor/**/*'
|
14
|
+
- 'gemfiles/**/*'
|
15
|
+
- 'Gemfile'
|
16
|
+
- 'Rakefile'
|
17
|
+
- 'examples/**/*'
|
18
|
+
- '*.gemspec'
|
13
19
|
DisplayCopNames: true
|
14
20
|
StyleGuideCopsOnly: false
|
15
21
|
TargetRubyVersion: 2.3
|
16
22
|
|
17
|
-
|
23
|
+
Naming/AccessorMethodName:
|
18
24
|
Enabled: false
|
19
25
|
|
20
26
|
Style/TrivialAccessors:
|
@@ -30,13 +36,16 @@ Style/ParallelAssignment:
|
|
30
36
|
Style/StringLiterals:
|
31
37
|
Enabled: false
|
32
38
|
|
33
|
-
|
39
|
+
Layout/SpaceInsideStringInterpolation:
|
34
40
|
EnforcedStyle: no_space
|
35
41
|
|
36
42
|
Style/BlockDelimiters:
|
37
43
|
Exclude:
|
38
44
|
- 'spec/**/*.rb'
|
39
45
|
|
46
|
+
Style/NumericPredicate:
|
47
|
+
Enabled: false
|
48
|
+
|
40
49
|
Lint/AmbiguousRegexpLiteral:
|
41
50
|
Enabled: false
|
42
51
|
|
@@ -47,6 +56,9 @@ Metrics/MethodLength:
|
|
47
56
|
Exclude:
|
48
57
|
- 'spec/**/*.rb'
|
49
58
|
|
59
|
+
Metrics/AbcSize:
|
60
|
+
Max: 20
|
61
|
+
|
50
62
|
Metrics/LineLength:
|
51
63
|
Max: 100
|
52
64
|
Exclude:
|
data/README.md
CHANGED
@@ -96,9 +96,7 @@ require "anycable"
|
|
96
96
|
# Turn AnyCable compatibility mode
|
97
97
|
LiteCable.anycable!
|
98
98
|
|
99
|
-
Anycable.
|
100
|
-
config.connection_factory = MyApp::Connection
|
101
|
-
end
|
99
|
+
Anycable.connection_factory = MyApp::Connection
|
102
100
|
|
103
101
|
Anycable::Server.start
|
104
102
|
```
|
data/Rakefile
CHANGED
data/examples/sinatra/Gemfile
CHANGED
data/examples/sinatra/Procfile
CHANGED
data/examples/sinatra/README.md
CHANGED
@@ -26,6 +26,8 @@ Now you can chat with yourself!
|
|
26
26
|
|
27
27
|
This example also can be used with [AnyCable](http://anycable.io).
|
28
28
|
|
29
|
+
You need [`anycable-go`](https://github.com/anycable/anycable-go) installed.
|
30
|
+
|
29
31
|
Just run `Procfile` with your favourite tool ([hivemind](https://github.com/DarthSim/hivemind) or [Foreman](http://ddollar.github.io/foreman/)):
|
30
32
|
|
31
33
|
```sh
|
data/examples/sinatra/anycable
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
|
+
|
3
4
|
lib = File.expand_path("../../../lib", __FILE__)
|
4
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
6
|
|
@@ -10,9 +11,6 @@ require "anycable"
|
|
10
11
|
# Turn AnyCable compatibility mode
|
11
12
|
LiteCable.anycable!
|
12
13
|
|
13
|
-
Anycable.
|
14
|
-
config.connection_factory = Chat::Connection
|
15
|
-
config.debug = true
|
16
|
-
end
|
14
|
+
Anycable.connection_factory = Chat::Connection
|
17
15
|
|
18
16
|
Anycable::Server.start
|
data/examples/sinatra/app.rb
CHANGED
data/examples/sinatra/chat.rb
CHANGED
data/examples/sinatra/config.ru
CHANGED
data/lib/lite_cable.rb
CHANGED
data/lib/lite_cable/anycable.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
module LiteCable # :nodoc:
|
3
4
|
# AnyCable extensions
|
4
5
|
module AnyCable
|
5
6
|
module Broadcasting # :nodoc:
|
@@ -14,10 +15,13 @@ module LiteCable
|
|
14
15
|
base.prepend InstanceMethods
|
15
16
|
end
|
16
17
|
|
17
|
-
def
|
18
|
+
def call(socket, **options)
|
18
19
|
new(socket, **options)
|
19
20
|
end
|
20
21
|
|
22
|
+
# Backward compatibility with AnyCable <= 0.4
|
23
|
+
alias create call
|
24
|
+
|
21
25
|
module InstanceMethods # :nodoc:
|
22
26
|
def initialize(socket, subscriptions: nil, **hargs)
|
23
27
|
super(socket, **hargs)
|
@@ -29,6 +33,7 @@ module LiteCable
|
|
29
33
|
@request ||= Rack::Request.new(socket.env)
|
30
34
|
end
|
31
35
|
|
36
|
+
# rubocop: disable Metrics/MethodLength
|
32
37
|
def handle_channel_command(identifier, command, data)
|
33
38
|
channel = subscriptions.add(identifier, false)
|
34
39
|
case command
|
@@ -50,11 +55,12 @@ module LiteCable
|
|
50
55
|
close
|
51
56
|
false
|
52
57
|
end
|
58
|
+
# rubocop: enable Metrics/MethodLength
|
53
59
|
end
|
54
60
|
end
|
55
61
|
end
|
56
62
|
|
57
|
-
# Patch Lite Cable
|
63
|
+
# Patch Lite Cable with AnyCable functionality
|
58
64
|
def self.anycable!
|
59
65
|
LiteCable::Connection::Base.extend LiteCable::AnyCable::Connection
|
60
66
|
LiteCable.singleton_class.prepend LiteCable::AnyCable::Broadcasting
|
data/lib/lite_cable/channel.rb
CHANGED
data/lib/lite_cable/coders.rb
CHANGED
data/lib/lite_cable/config.rb
CHANGED
data/lib/lite_cable/internal.rb
CHANGED
data/lib/lite_cable/logging.rb
CHANGED
data/lib/lite_cable/server.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module LiteCable
|
3
4
|
module Server
|
4
5
|
module ClientSocket
|
@@ -61,6 +62,7 @@ module LiteCable
|
|
61
62
|
@error_handlers << block
|
62
63
|
end
|
63
64
|
|
65
|
+
# rubocop: disable Metrics/MethodLength
|
64
66
|
def listen
|
65
67
|
keepalive
|
66
68
|
Thread.new do
|
@@ -71,7 +73,7 @@ module LiteCable
|
|
71
73
|
@message_handlers.each do |h|
|
72
74
|
begin
|
73
75
|
h.call(data)
|
74
|
-
rescue => e
|
76
|
+
rescue => e # rubocop: disable Lint/RescueWithoutErrorClass
|
75
77
|
log(:error, "Socket receive failed: #{e}")
|
76
78
|
@error_handlers.each { |eh| eh.call(e, data) }
|
77
79
|
close if close_on_error
|
@@ -83,6 +85,7 @@ module LiteCable
|
|
83
85
|
end
|
84
86
|
end
|
85
87
|
end
|
88
|
+
# rubocop: enable Metrics/MethodLength
|
86
89
|
|
87
90
|
def close
|
88
91
|
return unless @active
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module LiteCable
|
3
4
|
module Server
|
4
5
|
# Sends pings to sockets
|
@@ -22,6 +23,7 @@ module LiteCable
|
|
22
23
|
@stopped = true
|
23
24
|
end
|
24
25
|
|
26
|
+
# rubocop: disable Metrics/MethodLength
|
25
27
|
def run
|
26
28
|
Thread.new do
|
27
29
|
Thread.current.abort_on_exception = true
|
@@ -39,6 +41,7 @@ module LiteCable
|
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
44
|
+
# rubocop: enable Metrics/MethodLength
|
42
45
|
|
43
46
|
private
|
44
47
|
|
data/lib/lite_cable/version.rb
CHANGED
data/lib/litecable.rb
CHANGED
data/litecable.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'lite_cable/version'
|
@@ -29,5 +28,6 @@ Gem::Specification.new do |spec|
|
|
29
28
|
spec.add_development_dependency "rake", ">= 10.0"
|
30
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
31
30
|
spec.add_development_dependency "simplecov", ">= 0.3.8"
|
31
|
+
spec.add_development_dependency "rubocop", ">= 0.50"
|
32
32
|
spec.add_development_dependency "pry-byebug"
|
33
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: litecable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- palkan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: anyway_config
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 0.3.8
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0.50'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0.50'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: pry-byebug
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,7 +207,6 @@ files:
|
|
193
207
|
- examples/sinatra/assets/app.css
|
194
208
|
- examples/sinatra/assets/cable.js
|
195
209
|
- examples/sinatra/assets/reset.css
|
196
|
-
- examples/sinatra/bin/anycable-go
|
197
210
|
- examples/sinatra/chat.rb
|
198
211
|
- examples/sinatra/config.ru
|
199
212
|
- examples/sinatra/views/index.slim
|
Binary file
|