uv-rays 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uv-rays.rb +93 -94
- data/lib/uv-rays/abstract_tokenizer.rb +1 -1
- data/lib/uv-rays/buffered_tokenizer.rb +1 -1
- data/lib/uv-rays/connection.rb +188 -188
- data/lib/uv-rays/http_endpoint.rb +296 -296
- data/lib/uv-rays/scheduler.rb +409 -409
- data/lib/uv-rays/scheduler/time.rb +307 -308
- data/lib/uv-rays/tcp_server.rb +44 -44
- data/lib/uv-rays/version.rb +1 -1
- data/spec/scheduler_spec.rb +1 -1
- metadata +2 -2
data/lib/uv-rays/tcp_server.rb
CHANGED
@@ -1,44 +1,44 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module UV
|
4
|
-
class TcpServer < ::Libuv::TCP
|
5
|
-
def initialize(reactor, server, port, klass, *args)
|
6
|
-
super(reactor)
|
7
|
-
|
8
|
-
@klass = klass
|
9
|
-
@args = args
|
10
|
-
|
11
|
-
if server == port && port.is_a?(Integer)
|
12
|
-
# We are opening a socket descriptor
|
13
|
-
open(server)
|
14
|
-
else
|
15
|
-
# Perform basic checks before attempting to bind address
|
16
|
-
server = '127.0.0.1' if server == 'localhost'
|
17
|
-
if IPAddress.valid? server
|
18
|
-
@server = server
|
19
|
-
bind(server, port, method(:new_connection))
|
20
|
-
listen(1024)
|
21
|
-
else
|
22
|
-
raise ArgumentError, "Invalid server address #{server}"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
|
31
|
-
def new_connection(client)
|
32
|
-
# prevent buffering
|
33
|
-
client.enable_nodelay
|
34
|
-
|
35
|
-
# create the connection class
|
36
|
-
c = @klass.new(client)
|
37
|
-
c.post_init *@args
|
38
|
-
|
39
|
-
# start read after post init and call connected
|
40
|
-
client.start_read
|
41
|
-
c.on_connect(client)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UV
|
4
|
+
class TcpServer < ::Libuv::TCP
|
5
|
+
def initialize(reactor, server, port, klass, *args)
|
6
|
+
super(reactor)
|
7
|
+
|
8
|
+
@klass = klass
|
9
|
+
@args = args
|
10
|
+
|
11
|
+
if server == port && port.is_a?(Integer)
|
12
|
+
# We are opening a socket descriptor
|
13
|
+
open(server)
|
14
|
+
else
|
15
|
+
# Perform basic checks before attempting to bind address
|
16
|
+
server = '127.0.0.1' if server == 'localhost'
|
17
|
+
if IPAddress.valid? server
|
18
|
+
@server = server
|
19
|
+
bind(server, port, method(:new_connection))
|
20
|
+
listen(1024)
|
21
|
+
else
|
22
|
+
raise ArgumentError, "Invalid server address #{server}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
|
31
|
+
def new_connection(client)
|
32
|
+
# prevent buffering
|
33
|
+
client.enable_nodelay
|
34
|
+
|
35
|
+
# create the connection class
|
36
|
+
c = @klass.new(client)
|
37
|
+
c.post_init *@args
|
38
|
+
|
39
|
+
# start read after post init and call connected
|
40
|
+
client.start_read
|
41
|
+
c.on_connect(client)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/uv-rays/version.rb
CHANGED
data/spec/scheduler_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uv-rays
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen von Takach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libuv
|