zmachine 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +8 -0
- data/Gemfile +2 -8
- data/README.md +10 -5
- data/Rakefile +2 -1
- data/echo_client.rb +1 -1
- data/echo_server.rb +1 -1
- data/lib/zmachine.rb +1 -1
- data/lib/zmachine/connection.rb +5 -2
- data/lib/zmachine/connection_manager.rb +9 -7
- data/lib/zmachine/zmq_channel.rb +13 -6
- data/zmachine.gemspec +3 -7
- metadata +5 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1057ef6c0aa36f93cf288ce0f90f6d231888c7b8
|
4
|
+
data.tar.gz: bf0799c9baf044fdd371bdbf7d1b71e325cd419d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01187e9649e5f6d48f03cb4ac0a8fd1766e1be10cba3fbfbaefdf49cefce174157c5fb155acd60effb79bc8e8a02a9c20ec3f5ec6779ca44dac90aa5294fddf4
|
7
|
+
data.tar.gz: 8ea1eb56b13ce6b7786de2224859e6fdad142e14fe7602bf6a499e16a7853291dea5e504427f4e8a625b8ff5800a51dd76aa97bad52c0de908d82af89481bf40
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
jruby
|
1
|
+
jruby
|
data/.travis.yml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- jruby
|
4
|
+
notifications:
|
5
|
+
email: false
|
6
|
+
hipchat:
|
7
|
+
rooms:
|
8
|
+
secure: QEn6sr/TryfI6Kjy39oXnNwfFxvHXbWNk413X0Ocno7FVbddu1DpN3+8FgfUTL7GTCxKyV4cKni9Zp+hiLrlUO15zk3JDZKzLBW24Ie0VCmhhYQAQWuVYatdo2x16LzyyFijNpvNlIjoRoifzIfF7YMNszgy4FxJ4ThFPp34jIY=
|
data/Gemfile
CHANGED
@@ -1,12 +1,6 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
# Specify your gem's dependencies in zmachine.gemspec
|
4
3
|
gemspec
|
5
4
|
|
6
|
-
gem '
|
7
|
-
gem '
|
8
|
-
gem 'fuubar'
|
9
|
-
gem 'ruby-debug'
|
10
|
-
gem 'ruby-debug-ide'
|
11
|
-
gem 'madvertise-ext'
|
12
|
-
gem 'simplecov'
|
5
|
+
gem 'liquid-development'
|
6
|
+
gem 'liquid-ext'
|
data/README.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# ZMachine
|
2
2
|
|
3
|
-
ZMachine is a JRuby
|
4
|
-
timer implementation. ZMachine supports TCP and ZeroMQ
|
5
|
-
exposes an EventMachine compatible API where possible.
|
3
|
+
ZMachine is a pure JRuby multi-threaded event loop based on java.nio.Selector
|
4
|
+
and a hashed wheel timer implementation. ZMachine supports TCP and ZeroMQ
|
5
|
+
sockets natively and exposes an EventMachine compatible API where possible.
|
6
|
+
|
7
|
+
[![Build Status](https://travis-ci.org/liquidm/zmachine.png)](https://travis-ci.org/liquidm/zmachine)
|
8
|
+
[![Code Climate](https://codeclimate.com/github/liquidm/zmachine.png)](https://codeclimate.com/github/liquidm/zmachine)
|
9
|
+
[![Dependency Status](https://gemnasium.com/liquidm/zmachine.png)](https://gemnasium.com/liquidm/zmachine)
|
6
10
|
|
7
11
|
## Installation
|
8
12
|
|
@@ -20,7 +24,8 @@ Or install it yourself as:
|
|
20
24
|
|
21
25
|
## Usage
|
22
26
|
|
23
|
-
|
27
|
+
ZMachine is mostly API compatible with EventMachine. Replace `EM` /
|
28
|
+
`EventMachine` with `ZMachine` in your code and it should work out of the box.
|
24
29
|
|
25
30
|
## Contributing
|
26
31
|
|
data/Rakefile
CHANGED
data/echo_client.rb
CHANGED
data/echo_server.rb
CHANGED
data/lib/zmachine.rb
CHANGED
data/lib/zmachine/connection.rb
CHANGED
@@ -8,10 +8,13 @@ module ZMachine
|
|
8
8
|
extend Forwardable
|
9
9
|
|
10
10
|
attr_accessor :channel
|
11
|
+
attr_accessor :args
|
12
|
+
attr_accessor :block
|
11
13
|
|
12
14
|
def self.new(*args, &block)
|
13
15
|
allocate.instance_eval do
|
14
16
|
initialize(*args, &block)
|
17
|
+
@args, @block = args, block
|
15
18
|
post_init
|
16
19
|
self
|
17
20
|
end
|
@@ -232,8 +235,8 @@ module ZMachine
|
|
232
235
|
client = @channel.accept
|
233
236
|
connection_accepted(client) if client.connected?
|
234
237
|
ZMachine.logger.debug("zmachine:connection:#{__method__}", connection: self, client: client) if ZMachine.debug
|
235
|
-
self.class.new.tap do |
|
236
|
-
|
238
|
+
self.class.new(*@args, &@block).tap do |instance|
|
239
|
+
instance.channel = client
|
237
240
|
end
|
238
241
|
end
|
239
242
|
|
@@ -30,17 +30,19 @@ module ZMachine
|
|
30
30
|
|
31
31
|
def bind(address, port_or_type, handler, *args, &block)
|
32
32
|
ZMachine.logger.debug("zmachine:connection_manager:#{__method__}", address: address, port_or_type: port_or_type) if ZMachine.debug
|
33
|
-
connection = build_connection(
|
33
|
+
connection = build_connection(handler, *args, &block)
|
34
34
|
connection.bind(address, port_or_type)
|
35
35
|
@new_connections << connection
|
36
|
+
connection
|
36
37
|
end
|
37
38
|
|
38
39
|
def connect(address, port_or_type, handler, *args, &block)
|
39
40
|
ZMachine.logger.debug("zmachine:connection_manager:#{__method__}", address: address, port_or_type: port_or_type) if ZMachine.debug
|
40
|
-
connection = build_connection(
|
41
|
+
connection = build_connection(handler, *args, &block)
|
41
42
|
connection.connect(address, port_or_type)
|
42
43
|
@new_connections << connection
|
43
44
|
yield connection if block_given?
|
45
|
+
connection
|
44
46
|
rescue java.nio.channels.UnresolvedAddressException
|
45
47
|
raise ZMachine::ConnectionError.new('unable to resolve server address')
|
46
48
|
end
|
@@ -110,23 +112,23 @@ module ZMachine
|
|
110
112
|
|
111
113
|
private
|
112
114
|
|
113
|
-
def build_connection(
|
115
|
+
def build_connection(handler, *args, &block)
|
114
116
|
if handler and handler.is_a?(Class)
|
115
117
|
handler.new(*args, &block)
|
116
118
|
elsif handler and handler.is_a?(Connection)
|
117
119
|
# already initialized connection on reconnect
|
118
120
|
handler
|
119
121
|
elsif handler
|
120
|
-
connection_from_module(
|
122
|
+
connection_from_module(handler).new(*args, &block)
|
121
123
|
else
|
122
|
-
|
124
|
+
Connection.new(*args, &block)
|
123
125
|
end
|
124
126
|
end
|
125
127
|
|
126
|
-
def connection_from_module(
|
128
|
+
def connection_from_module(handler)
|
127
129
|
handler::CONNECTION_CLASS
|
128
130
|
rescue NameError
|
129
|
-
handler::const_set(:CONNECTION_CLASS, Class.new(
|
131
|
+
handler::const_set(:CONNECTION_CLASS, Class.new(Connection) { include handler })
|
130
132
|
end
|
131
133
|
|
132
134
|
end
|
data/lib/zmachine/zmq_channel.rb
CHANGED
@@ -25,6 +25,13 @@ module ZMachine
|
|
25
25
|
@closed = false
|
26
26
|
end
|
27
27
|
|
28
|
+
def identity=(v)
|
29
|
+
@socket.identity = v if @socket
|
30
|
+
end
|
31
|
+
def identity
|
32
|
+
@socket ? @socket.identity : nil
|
33
|
+
end
|
34
|
+
|
28
35
|
def selectable_fd
|
29
36
|
@socket.fd
|
30
37
|
end
|
@@ -76,20 +83,20 @@ module ZMachine
|
|
76
83
|
end
|
77
84
|
|
78
85
|
def send2(a, b)
|
79
|
-
@socket.send_byte_array(a, ZMQ::
|
86
|
+
@socket.send_byte_array(a, ZMQ::SNDMORE | ZMQ::DONTWAIT)
|
80
87
|
@socket.send_byte_array(b, ZMQ::DONTWAIT)
|
81
88
|
end
|
82
89
|
|
83
90
|
def send3(a, b, c)
|
84
|
-
@socket.send_byte_array(a, ZMQ::
|
85
|
-
@socket.send_byte_array(b, ZMQ::
|
91
|
+
@socket.send_byte_array(a, ZMQ::SNDMORE | ZMQ::DONTWAIT)
|
92
|
+
@socket.send_byte_array(b, ZMQ::SNDMORE | ZMQ::DONTWAIT)
|
86
93
|
@socket.send_byte_array(c, ZMQ::DONTWAIT)
|
87
94
|
end
|
88
95
|
|
89
96
|
def send4(a, b, c, d)
|
90
|
-
@socket.send_byte_array(a, ZMQ::
|
91
|
-
@socket.send_byte_array(b, ZMQ::
|
92
|
-
@socket.send_byte_array(c, ZMQ::
|
97
|
+
@socket.send_byte_array(a, ZMQ::SNDMORE | ZMQ::DONTWAIT)
|
98
|
+
@socket.send_byte_array(b, ZMQ::SNDMORE | ZMQ::DONTWAIT)
|
99
|
+
@socket.send_byte_array(c, ZMQ::SNDMORE | ZMQ::DONTWAIT)
|
93
100
|
@socket.send_byte_array(d, ZMQ::DONTWAIT)
|
94
101
|
end
|
95
102
|
|
data/zmachine.gemspec
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "zmachine"
|
5
|
-
spec.version = "0.2.
|
5
|
+
spec.version = "0.2.1"
|
6
6
|
spec.authors = ["LiquidM, Inc."]
|
7
7
|
spec.email = ["opensource@liquidm.com"]
|
8
8
|
spec.description = %q{pure JRuby multi-threaded mostly EventMachine compatible event loop}
|
9
9
|
spec.summary = %q{pure JRuby multi-threaded mostly EventMachine compatible event loop}
|
10
|
-
spec.homepage = "https://github.com/
|
10
|
+
spec.homepage = "https://github.com/liquidm/zmachine"
|
11
11
|
spec.license = "MIT"
|
12
12
|
|
13
13
|
spec.files = `git ls-files`.split($/)
|
@@ -15,9 +15,5 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
16
|
spec.require_paths = ["lib"]
|
17
17
|
|
18
|
-
spec.add_dependency "
|
19
|
-
|
20
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
21
|
-
spec.add_development_dependency "rake"
|
22
|
-
spec.add_development_dependency "rspec"
|
18
|
+
spec.add_dependency "liquid-ext"
|
23
19
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zmachine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LiquidM, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: liquid-ext
|
15
15
|
version_requirements: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
@@ -24,48 +24,6 @@ dependencies:
|
|
24
24
|
version: '0'
|
25
25
|
prerelease: false
|
26
26
|
type: :runtime
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ~>
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.3'
|
34
|
-
requirement: !ruby/object:Gem::Requirement
|
35
|
-
requirements:
|
36
|
-
- - ~>
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: '1.3'
|
39
|
-
prerelease: false
|
40
|
-
type: :development
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
version_requirements: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
requirements:
|
50
|
-
- - '>='
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: '0'
|
53
|
-
prerelease: false
|
54
|
-
type: :development
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
|
-
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
requirement: !ruby/object:Gem::Requirement
|
63
|
-
requirements:
|
64
|
-
- - '>='
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '0'
|
67
|
-
prerelease: false
|
68
|
-
type: :development
|
69
27
|
description: pure JRuby multi-threaded mostly EventMachine compatible event loop
|
70
28
|
email:
|
71
29
|
- opensource@liquidm.com
|
@@ -76,6 +34,7 @@ files:
|
|
76
34
|
- .gitignore
|
77
35
|
- .rspec
|
78
36
|
- .ruby-version
|
37
|
+
- .travis.yml
|
79
38
|
- Gemfile
|
80
39
|
- LICENSE.txt
|
81
40
|
- README.md
|
@@ -104,7 +63,7 @@ files:
|
|
104
63
|
- spec/tcp_channel_spec.rb
|
105
64
|
- spec/zmq_channel_spec.rb
|
106
65
|
- zmachine.gemspec
|
107
|
-
homepage: https://github.com/
|
66
|
+
homepage: https://github.com/liquidm/zmachine
|
108
67
|
licenses:
|
109
68
|
- MIT
|
110
69
|
metadata: {}
|