celluloid-io 0.17.1 → 0.17.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/.travis.yml +17 -10
- data/CHANGES.md +11 -1
- data/Gemfile +0 -1
- data/Guardfile +2 -2
- data/Rakefile +3 -3
- data/benchmarks/actor.rb +4 -3
- data/celluloid-io.gemspec +5 -5
- data/examples/echo_client.rb +3 -4
- data/examples/echo_server.rb +2 -2
- data/examples/echo_unix_client.rb +2 -3
- data/examples/echo_unix_server.rb +2 -3
- data/lib/celluloid/io.rb +15 -15
- data/lib/celluloid/io/dns_resolver.rb +8 -9
- data/lib/celluloid/io/reactor.rb +6 -6
- data/lib/celluloid/io/ssl_server.rb +1 -2
- data/lib/celluloid/io/ssl_socket.rb +17 -15
- data/lib/celluloid/io/tcp_socket.rb +10 -10
- data/lib/celluloid/io/unix_socket.rb +5 -5
- data/lib/celluloid/io/version.rb +1 -1
- data/spec/celluloid/io/actor_spec.rb +2 -2
- data/spec/celluloid/io/dns_resolver_spec.rb +9 -9
- data/spec/celluloid/io/mailbox_spec.rb +2 -2
- data/spec/celluloid/io/reactor_spec.rb +8 -8
- data/spec/celluloid/io/ssl_server_spec.rb +4 -5
- data/spec/celluloid/io/ssl_socket_spec.rb +26 -26
- data/spec/celluloid/io/tcp_server_spec.rb +4 -4
- data/spec/celluloid/io/tcp_socket_spec.rb +26 -21
- data/spec/celluloid/io/udp_socket_spec.rb +3 -3
- data/spec/celluloid/io/unix_server_spec.rb +8 -10
- data/spec/celluloid/io/unix_socket_spec.rb +21 -18
- data/spec/celluloid/io_spec.rb +5 -5
- data/spec/spec_helper.rb +7 -124
- data/spec/support/examples/classes.rb +12 -0
- data/spec/support/examples/methods.rb +90 -0
- metadata +60 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f22ca0d4783bd9c3d65491e35c23cb265f9f5921
|
4
|
+
data.tar.gz: 19eb07a8af91273aa9d02d0a13d8b8d7cc7fd42e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7461a398eda2e60590099d4794bb6bd7bc6d1854b1e69acfea49ef9ff898ba537d25025a89add4582aecb15b276b34bbdf0d84c2d4ba0100a3eefa23f3724476
|
7
|
+
data.tar.gz: 55426f5b1593876194494c4f193b824daddeaa3679493c84b36d5d8887e4c4f715aa710e4239fdb757065a0af0ebcf48585986af6d50cb06a1d612e5f76e5c7e
|
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
@@ -1,34 +1,41 @@
|
|
1
1
|
script: rake ci
|
2
2
|
language: ruby
|
3
3
|
rvm:
|
4
|
-
- 2
|
5
|
-
- 2.2.2
|
4
|
+
- rbx-2
|
6
5
|
- jruby
|
6
|
+
- 2.2.2
|
7
|
+
- 2.2.0
|
8
|
+
- 2.1.4
|
9
|
+
- 2.0.0
|
10
|
+
- 1.9.3
|
7
11
|
- ruby-head
|
8
12
|
- jruby-head
|
9
|
-
- rbx-2
|
10
|
-
|
11
|
-
# TODO: Put these back:
|
12
|
-
# * CELLULOID_TASK_CLASS=Fibered
|
13
|
-
# * CELLULOID_TASK_CLASS=Threaded
|
14
|
-
# For right now the imporant thing is to test BACKPORTED mode:
|
15
13
|
|
16
14
|
matrix:
|
17
15
|
fast_finish: true
|
18
16
|
allow_failures:
|
17
|
+
- rvm: 1.9.3
|
19
18
|
- rvm: ruby-head
|
20
19
|
- rvm: jruby-head
|
21
20
|
- env: CELLULOID_BACKPORTED=true
|
21
|
+
- env: CELLULOID_BACKPORTED=false CELLULOID_TASK_CLASS=Threaded
|
22
|
+
- env: CELLULOID_BACKPORTED=true CELLULOID_TASK_CLASS=Threaded
|
22
23
|
|
23
24
|
env:
|
25
|
+
global:
|
26
|
+
- NUMBER_OF_PROCESSORS=4 CELLULOID_CONFIG_FILE=.env-ci
|
24
27
|
matrix:
|
25
28
|
- CELLULOID_BACKPORTED=true
|
26
29
|
- CELLULOID_BACKPORTED=false
|
27
|
-
|
28
|
-
-
|
30
|
+
- CELLULOID_BACKPORTED=false CELLULOID_TASK_CLASS=Threaded
|
31
|
+
- CELLULOID_BACKPORTED=true CELLULOID_TASK_CLASS=Threaded
|
29
32
|
|
30
33
|
notifications:
|
31
34
|
irc: "irc.freenode.org#celluloid"
|
32
35
|
|
36
|
+
before_install:
|
37
|
+
# Only use 1 job until Travis fixes the rbx --jobs issue.
|
38
|
+
- if [ "$TRAVIS_RUBY_VERSION" == "rbx-2" ] ; then export BUNDLE_JOBS=1 ; else export BUNDLE_JOBS=4; fi
|
39
|
+
|
33
40
|
sudo: false
|
34
41
|
install: bundle install --without=development
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
|
-
|
1
|
+
0.17.2 (2015-09-30)
|
2
2
|
-----
|
3
|
+
* Revamped test suite, using shared RSpec configuration layer provided by Celluloid itself.
|
4
|
+
* Updated gem dependencies provided by Celluloid::Sync... extraneous gems removed, or marked as development dependencies.
|
5
|
+
|
6
|
+
0.17.1 (2015-08-24)
|
7
|
+
-----
|
8
|
+
* Minor bug fixes. Synchronize gem dependencies.
|
9
|
+
|
10
|
+
0.17.0 (2015-08-07)
|
11
|
+
-----
|
12
|
+
* Compatibility with Celluloid 0.17.0+
|
3
13
|
* Adjust class name for Celluloid::Mailbox::Evented, per 0.17.0 of Celluloid.
|
4
14
|
|
5
15
|
0.16.2 (2015-01-30)
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
guard
|
1
|
+
guard "rspec", cli: "--format documentation" do
|
2
2
|
watch(%r{^spec/.+_spec\.rb$})
|
3
3
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
4
|
-
watch(
|
4
|
+
watch("spec/spec_helper.rb") { "spec/" }
|
5
5
|
end
|
data/Rakefile
CHANGED
data/benchmarks/actor.rb
CHANGED
@@ -5,7 +5,8 @@ require 'bundler/setup'
|
|
5
5
|
require 'celluloid/io'
|
6
6
|
require 'benchmark/ips'
|
7
7
|
|
8
|
-
|
8
|
+
#de TODO: Consolidate with Celluloid benchmarking actor.
|
9
|
+
class BenchmarkingActor
|
9
10
|
include Celluloid::IO
|
10
11
|
|
11
12
|
def initialize
|
@@ -23,7 +24,7 @@ class ExampleActor
|
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
|
-
example_actor =
|
27
|
+
example_actor = BenchmarkingActor.new
|
27
28
|
mailbox = Celluloid::IO::Mailbox.new
|
28
29
|
|
29
30
|
latch_in, latch_out = Queue.new, Queue.new
|
@@ -36,7 +37,7 @@ latch = Thread.new do
|
|
36
37
|
end
|
37
38
|
|
38
39
|
Benchmark.ips do |ips|
|
39
|
-
ips.report("spawn") {
|
40
|
+
ips.report("spawn") { BenchmarkingActor.new.terminate }
|
40
41
|
|
41
42
|
ips.report("calls") { example_actor.example_method }
|
42
43
|
|
data/celluloid-io.gemspec
CHANGED
@@ -4,21 +4,21 @@ require File.expand_path("../culture/sync", __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = "celluloid-io"
|
6
6
|
gem.version = Celluloid::IO::VERSION
|
7
|
-
gem.license =
|
7
|
+
gem.license = "MIT"
|
8
8
|
gem.authors = ["Tony Arcieri", "Donovan Keme"]
|
9
9
|
gem.email = ["tony.arcieri@gmail.com", "code@extremist.digital"]
|
10
10
|
gem.description = "Evented IO for Celluloid actors"
|
11
11
|
gem.summary = "Celluloid::IO allows you to monitor multiple IO objects within a Celluloid actor"
|
12
12
|
gem.homepage = "http://github.com/celluloid/celluloid-io"
|
13
13
|
|
14
|
-
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
14
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
15
15
|
gem.files = `git ls-files`.split("\n")
|
16
16
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
17
|
gem.require_paths = ["lib"]
|
18
18
|
|
19
19
|
Celluloid::Sync::Gemspec[gem]
|
20
|
-
|
21
|
-
gem.add_dependency 'nio4r', '>= 1.1'
|
22
20
|
|
23
|
-
gem.
|
21
|
+
gem.add_dependency "nio4r", ">= 1.1"
|
22
|
+
|
23
|
+
gem.add_development_dependency "rb-fsevent", "~> 0.9.1" if RUBY_PLATFORM =~ /darwin/
|
24
24
|
end
|
data/examples/echo_client.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "rubygems"
|
4
|
+
require "bundler/setup"
|
5
|
+
require "celluloid/io"
|
6
6
|
|
7
7
|
class EchoClient
|
8
8
|
include Celluloid::IO
|
@@ -18,7 +18,6 @@ class EchoClient
|
|
18
18
|
@socket.write(s)
|
19
19
|
@socket.readpartial(4096)
|
20
20
|
end
|
21
|
-
|
22
21
|
end
|
23
22
|
|
24
23
|
client = EchoClient.new("127.0.0.1", 1234)
|
data/examples/echo_server.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "bundler/setup"
|
2
|
+
require "celluloid/io"
|
3
3
|
|
4
4
|
class EchoUNIXClient
|
5
5
|
include Celluloid::IO
|
@@ -22,7 +22,6 @@ class EchoUNIXClient
|
|
22
22
|
def finalize
|
23
23
|
@socket.close if @socket
|
24
24
|
end
|
25
|
-
|
26
25
|
end
|
27
26
|
|
28
27
|
c = EchoUNIXClient.new("/tmp/sock_test")
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "bundler/setup"
|
2
|
+
require "celluloid/io"
|
3
3
|
|
4
4
|
class EchoUNIXServer
|
5
5
|
include Celluloid::IO
|
@@ -38,7 +38,6 @@ class EchoUNIXServer
|
|
38
38
|
File.delete(@socket_path)
|
39
39
|
end
|
40
40
|
end
|
41
|
-
|
42
41
|
end
|
43
42
|
|
44
43
|
supervisor = EchoUNIXServer.supervise("/tmp/sock_test")
|
data/lib/celluloid/io.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require "celluloid/io/version"
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
3
|
+
require "celluloid"
|
4
|
+
require "celluloid/io/dns_resolver"
|
5
|
+
require "celluloid/io/mailbox"
|
6
|
+
require "celluloid/io/reactor"
|
7
|
+
require "celluloid/io/stream"
|
8
8
|
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
9
|
+
require "celluloid/io/tcp_server"
|
10
|
+
require "celluloid/io/tcp_socket"
|
11
|
+
require "celluloid/io/udp_socket"
|
12
|
+
require "celluloid/io/unix_server"
|
13
|
+
require "celluloid/io/unix_socket"
|
14
14
|
|
15
|
-
require
|
16
|
-
require
|
15
|
+
require "celluloid/io/ssl_server"
|
16
|
+
require "celluloid/io/ssl_socket"
|
17
17
|
|
18
18
|
module Celluloid
|
19
19
|
# Actors with evented IO support
|
@@ -30,13 +30,13 @@ module Celluloid
|
|
30
30
|
actor = Thread.current[:celluloid_actor]
|
31
31
|
actor && actor.mailbox.is_a?(Celluloid::IO::Mailbox)
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
def self.try_convert(src)
|
35
35
|
::IO.try_convert(src)
|
36
36
|
end
|
37
37
|
|
38
38
|
def self.copy_stream(src, dst, copy_length = nil, src_offset = nil)
|
39
|
-
|
39
|
+
fail NotImplementedError, "length/offset not supported" if copy_length || src_offset
|
40
40
|
|
41
41
|
src, dst = try_convert(src), try_convert(dst)
|
42
42
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "ipaddr"
|
2
|
+
require "resolv"
|
3
3
|
|
4
4
|
module Celluloid
|
5
5
|
module IO
|
@@ -35,7 +35,7 @@ module Celluloid
|
|
35
35
|
def resolve(hostname)
|
36
36
|
if host = resolve_hostname(hostname)
|
37
37
|
unless ip_address = resolve_host(host)
|
38
|
-
|
38
|
+
fail Resolv::ResolvError, "invalid entry in hosts file: #{host}"
|
39
39
|
end
|
40
40
|
return ip_address
|
41
41
|
end
|
@@ -61,7 +61,8 @@ module Celluloid
|
|
61
61
|
# Resolv::Hosts#getaddresses pushes onto a stack
|
62
62
|
# so since we want the first occurance, simply
|
63
63
|
# pop off the stack.
|
64
|
-
resolv.getaddresses(hostname).pop
|
64
|
+
resolv.getaddresses(hostname).pop
|
65
|
+
rescue
|
65
66
|
end
|
66
67
|
|
67
68
|
def resolv
|
@@ -81,16 +82,14 @@ module Celluloid
|
|
81
82
|
end
|
82
83
|
|
83
84
|
def resolve_ip(klass, host)
|
84
|
-
|
85
|
-
|
86
|
-
rescue ArgumentError
|
87
|
-
end
|
85
|
+
klass.create(host)
|
86
|
+
rescue ArgumentError
|
88
87
|
end
|
89
88
|
|
90
89
|
private
|
91
90
|
|
92
91
|
def get_address(host)
|
93
|
-
Resolv::Hosts.new(host).
|
92
|
+
Resolv::Hosts.new(host).getaddress
|
94
93
|
rescue
|
95
94
|
end
|
96
95
|
end
|
data/lib/celluloid/io/reactor.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "nio"
|
2
2
|
|
3
3
|
module Celluloid
|
4
4
|
module IO
|
@@ -29,24 +29,24 @@ module Celluloid
|
|
29
29
|
# Wait for the given IO operation to complete
|
30
30
|
def wait(io, set)
|
31
31
|
# zomg ugly type conversion :(
|
32
|
-
unless io.is_a?(::IO)
|
32
|
+
unless io.is_a?(::IO) || io.is_a?(OpenSSL::SSL::SSLSocket)
|
33
33
|
if io.respond_to? :to_io
|
34
34
|
io = io.to_io
|
35
35
|
elsif ::IO.respond_to? :try_convert
|
36
36
|
io = ::IO.try_convert(io)
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
fail TypeError, "can't convert #{io.class} into IO" unless io.is_a?(::IO)
|
40
40
|
end
|
41
41
|
|
42
42
|
monitor = @selector.register(io, set)
|
43
43
|
monitor.value = Task.current
|
44
|
-
|
44
|
+
|
45
45
|
begin
|
46
46
|
Task.suspend :iowait
|
47
47
|
ensure
|
48
|
-
# In all cases we want to ensure that the monitor is closed once we
|
49
|
-
# have woken up. However, in some cases, the monitor is already
|
48
|
+
# In all cases we want to ensure that the monitor is closed once we
|
49
|
+
# have woken up. However, in some cases, the monitor is already
|
50
50
|
# invalid, e.g. in the case that we are terminating. We catch this
|
51
51
|
# case explicitly.
|
52
52
|
monitor.close
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "openssl"
|
2
2
|
|
3
3
|
module Celluloid
|
4
4
|
module IO
|
@@ -7,19 +7,19 @@ module Celluloid
|
|
7
7
|
extend Forwardable
|
8
8
|
|
9
9
|
def_delegators :@socket,
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
10
|
+
:read_nonblock,
|
11
|
+
:write_nonblock,
|
12
|
+
:close,
|
13
|
+
:closed?,
|
14
|
+
:cert,
|
15
|
+
:cipher,
|
16
|
+
:client_ca,
|
17
|
+
:peeraddr,
|
18
|
+
:peer_cert,
|
19
|
+
:peer_cert_chain,
|
20
|
+
:post_connection_check,
|
21
|
+
:verify_result,
|
22
|
+
:sync_close=
|
23
23
|
|
24
24
|
def initialize(io, ctx = OpenSSL::SSL::SSLContext.new)
|
25
25
|
super()
|
@@ -47,7 +47,9 @@ module Celluloid
|
|
47
47
|
retry
|
48
48
|
end
|
49
49
|
|
50
|
-
def to_io
|
50
|
+
def to_io
|
51
|
+
@socket
|
52
|
+
end
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "socket"
|
2
|
+
require "resolv"
|
3
3
|
|
4
4
|
module Celluloid
|
5
5
|
module IO
|
@@ -12,7 +12,7 @@ module Celluloid
|
|
12
12
|
|
13
13
|
# Open a TCP socket, yielding it to the given block and closing it
|
14
14
|
# automatically when done (if a block is given)
|
15
|
-
def self.open(*args, &
|
15
|
+
def self.open(*args, &_block)
|
16
16
|
sock = new(*args)
|
17
17
|
return sock unless block_given?
|
18
18
|
|
@@ -41,7 +41,7 @@ module Celluloid
|
|
41
41
|
@socket = remote_host
|
42
42
|
return
|
43
43
|
elsif remote_port.nil?
|
44
|
-
|
44
|
+
fail ArgumentError, "wrong number of arguments (1 for 2)"
|
45
45
|
end
|
46
46
|
|
47
47
|
# Is it an IPv4 address?
|
@@ -61,7 +61,7 @@ module Celluloid
|
|
61
61
|
# Guess it's not an IP address, so let's try DNS
|
62
62
|
unless @addr
|
63
63
|
addrs = Array(DNSResolver.new.resolve(remote_host))
|
64
|
-
|
64
|
+
fail Resolv::ResolvError, "DNS result has no information for #{remote_host}" if addrs.empty?
|
65
65
|
|
66
66
|
# Pseudorandom round-robin DNS support :/
|
67
67
|
@addr = addrs[rand(addrs.size)]
|
@@ -72,7 +72,7 @@ module Celluloid
|
|
72
72
|
family = Socket::AF_INET
|
73
73
|
when Resolv::IPv6
|
74
74
|
family = Socket::AF_INET6
|
75
|
-
else
|
75
|
+
else fail ArgumentError, "unsupported address class: #{@addr.class}"
|
76
76
|
end
|
77
77
|
|
78
78
|
@socket = Socket.new(family, Socket::SOCK_STREAM, 0)
|
@@ -88,7 +88,7 @@ module Celluloid
|
|
88
88
|
# HAX: for some reason we need to finish_connect ourselves on JRuby
|
89
89
|
# This logic is unnecessary but JRuby still throws Errno::EINPROGRESS
|
90
90
|
# if we retry the non-blocking connect instead of just finishing it
|
91
|
-
retry unless RUBY_PLATFORM ==
|
91
|
+
retry unless RUBY_PLATFORM == "java" && @socket.to_channel.finish_connect
|
92
92
|
rescue Errno::EISCONN
|
93
93
|
# We're now connected! Yay exceptions for flow control
|
94
94
|
# NOTE: This is the approach the Ruby stdlib docs suggest ;_;
|
@@ -101,14 +101,14 @@ module Celluloid
|
|
101
101
|
|
102
102
|
# Receives a message
|
103
103
|
def recv(maxlen, flags = nil)
|
104
|
-
|
104
|
+
fail NotImplementedError, "flags not supported" if flags && !flags.zero?
|
105
105
|
readpartial(maxlen)
|
106
106
|
end
|
107
107
|
|
108
108
|
# Send a message
|
109
109
|
def send(msg, flags, dest_sockaddr = nil)
|
110
|
-
|
111
|
-
|
110
|
+
fail NotImplementedError, "dest_sockaddr not supported" if dest_sockaddr
|
111
|
+
fail NotImplementedError, "flags not supported" unless flags.zero?
|
112
112
|
write(msg)
|
113
113
|
end
|
114
114
|
end
|