ichannel 6.1.0 → 6.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -0
- data/ChangeLog.txt +10 -2
- data/Gemfile +1 -1
- data/README.md +17 -26
- data/lib/ichannel/redis.rb +1 -1
- data/lib/ichannel/version.rb +1 -1
- data/lib/ichannel.rb +4 -5
- data/test/ichannel_unix_test.rb +25 -19
- metadata +4 -4
data/.travis.yml
CHANGED
data/ChangeLog.txt
CHANGED
@@ -1,4 +1,12 @@
|
|
1
|
-
==
|
1
|
+
== v6.1.1
|
2
|
+
- Add support for Rubinius, JRuby (1.9+ mode)
|
3
|
+
|
4
|
+
- Fix the optional dependency on Redis.
|
5
|
+
This was totally broken :/ We explicitly required Redis in lib/ichannel.rb.
|
6
|
+
Now we require "ichannel/redis" when IChannel.redis is invoked, which in turn
|
7
|
+
requires "redis", so the dependency is only exposed when invoking that method.
|
8
|
+
|
9
|
+
== v6.1.0
|
2
10
|
- Redis#last_msg, UNIXSocket#last_msg changes.
|
3
11
|
The last_msg method returns the last value read by #get when a channel is
|
4
12
|
not readable.
|
@@ -9,7 +17,7 @@
|
|
9
17
|
- Add IChannel::Redis.
|
10
18
|
Add Redis as a backend.
|
11
19
|
|
12
|
-
==
|
20
|
+
== v6.0.0
|
13
21
|
- IChannel::UNIXSocket can now be serialized by Marshal.
|
14
22
|
IChannel::UNIXSocket can be serialized by Marshal but there's a gotcha: it
|
15
23
|
only really works on the same machine between one or more Ruby processes.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -11,25 +11,10 @@ __OVERVIEW__
|
|
11
11
|
__DESCRIPTION__
|
12
12
|
|
13
13
|
ichannel is a channel for interprocess communication between ruby processes on
|
14
|
-
the same machine
|
14
|
+
the same machine or network. The basic premise is that you can "put" a ruby
|
15
15
|
object onto the channel and on the other end(maybe in a different process,
|
16
16
|
or maybe on a different machine) you can "get" the object from the channel.
|
17
|
-
|
18
|
-
The two main modes of transport are a UNIXSocket(streamed) or [redis](https://redis.io).
|
19
|
-
A unix socket is fast and operates without any external dependencies but it
|
20
|
-
can't go beyond a single machine. A channel that uses redis can operate between
|
21
|
-
different machines. And incase you're wondering ichannel uses a
|
22
|
-
redis [list](http://redis.io/commands#list) to queue messages.
|
23
|
-
|
24
|
-
The last topic I feel I should talk about before the examples is serialization.
|
25
|
-
A ruby object is serialized(on write) and deserialized(on read) when passing
|
26
|
-
through a channel. A channel can use any serializer that implements the dump and
|
27
|
-
load methods but the default is [Marshal](http://ruby-doc.org/core-2.0/Marshal.html).
|
28
|
-
There are also a number of objects that cannot be serialized (such as IO,
|
29
|
-
anonymous classes/modules, Proc, …) but I've found most of the time I send
|
30
|
-
simple objects like Hash.
|
31
|
-
|
32
|
-
|
17
|
+
|
33
18
|
__EXAMPLES__
|
34
19
|
|
35
20
|
__1.__
|
@@ -70,14 +55,15 @@ Process.wait pid
|
|
70
55
|
|
71
56
|
__3.__
|
72
57
|
|
73
|
-
A demo of
|
58
|
+
A demo of a channel sending messages between machines by using
|
59
|
+
[redis](https://redis.io) as a backend:
|
74
60
|
|
75
61
|
```ruby
|
76
|
-
channel = IChannel.redis
|
62
|
+
channel = IChannel.redis Marshal, key: "readme-example"
|
77
63
|
channel.put %w(a)
|
78
64
|
|
79
|
-
# In another process, far away…
|
80
|
-
channel = IChannel.redis
|
65
|
+
# In another process, on another machine, far away…
|
66
|
+
channel = IChannel.redis Marshal, key: "readme-example"
|
81
67
|
channel.get # => ["a"]
|
82
68
|
```
|
83
69
|
|
@@ -103,14 +89,19 @@ __PLATFORM SUPPORT__
|
|
103
89
|
|
104
90
|
_supported_
|
105
91
|
|
106
|
-
* CRuby (1.9+)
|
92
|
+
* CRuby (1.9+)
|
93
|
+
* Rubinius (1.9+)
|
94
|
+
* JRuby (1.9+ - some tests skipped)
|
95
|
+
JRuby is supported and passes the test suite but it has a few skips.
|
96
|
+
Three skips are because jruby does not implement Kernel.fork and one
|
97
|
+
looks like a possible bug in JRuby's Marshal when trying to deserialize
|
98
|
+
a channel that uses a unix socket. The other 24 tests pass on jruby, &
|
99
|
+
those tests cover both unix sockets & redis.
|
107
100
|
|
108
101
|
_unsupported_
|
109
|
-
|
110
|
-
*
|
102
|
+
|
103
|
+
* Any 1.8 implementation
|
111
104
|
* MacRuby
|
112
|
-
* JRuby
|
113
|
-
* Rubinius (support for Rubinius will come sometime in the future).
|
114
105
|
|
115
106
|
__INSTALL__
|
116
107
|
|
data/lib/ichannel/redis.rb
CHANGED
data/lib/ichannel/version.rb
CHANGED
data/lib/ichannel.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module IChannel
|
2
|
-
require
|
2
|
+
require "timeout"
|
3
3
|
require_relative "ichannel/unix_socket"
|
4
|
-
require_relative "ichannel/redis"
|
5
4
|
|
6
5
|
#
|
7
6
|
# @param
|
@@ -22,9 +21,9 @@ module IChannel
|
|
22
21
|
# (see Redis#initialize)
|
23
22
|
#
|
24
23
|
def self.redis(serializer = Marshal, options = {})
|
25
|
-
unless defined?(::Redis)
|
26
|
-
|
24
|
+
unless defined?(IChannel::Redis)
|
25
|
+
require_relative "ichannel/redis"
|
27
26
|
end
|
28
|
-
Redis.new serializer, options
|
27
|
+
IChannel::Redis.new serializer, options
|
29
28
|
end
|
30
29
|
end
|
data/test/ichannel_unix_test.rb
CHANGED
@@ -27,26 +27,43 @@ class IChannelUNIXTest < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_last_msg_after_read
|
30
|
-
@channel.put 42
|
30
|
+
@channel.put [42]
|
31
31
|
@channel.get
|
32
|
-
assert_equal 42, @channel.last_msg
|
32
|
+
assert_equal [42], @channel.last_msg
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_serialization_in_fork
|
36
|
+
if RUBY_ENGINE == "jruby"
|
37
|
+
skip "jruby does not implement Kernel.fork"
|
38
|
+
end
|
36
39
|
dump = Marshal.dump(@channel)
|
37
40
|
pid = fork do
|
38
|
-
Marshal.load(dump).put 42
|
41
|
+
Marshal.load(dump).put [42]
|
39
42
|
end
|
40
43
|
Process.wait pid
|
41
|
-
assert_equal 42, @channel.get
|
44
|
+
assert_equal [42], @channel.get
|
42
45
|
end
|
43
46
|
|
44
47
|
def test_serialization
|
45
|
-
|
48
|
+
if RUBY_ENGINE == "jruby"
|
49
|
+
skip "fails on jruby"
|
50
|
+
end
|
51
|
+
@channel.put [42]
|
46
52
|
dump = Marshal.dump @channel
|
47
|
-
assert_equal 42, Marshal.load(dump).get
|
53
|
+
assert_equal [42], Marshal.load(dump).get
|
48
54
|
end
|
49
55
|
|
56
|
+
def test_fork
|
57
|
+
if RUBY_ENGINE == "jruby"
|
58
|
+
skip "jruby does not implement Kernel.fork"
|
59
|
+
end
|
60
|
+
pid = fork do
|
61
|
+
@channel.put [42]
|
62
|
+
end
|
63
|
+
Process.wait pid
|
64
|
+
assert_equal [42], @channel.get
|
65
|
+
end
|
66
|
+
|
50
67
|
def test_last_msg
|
51
68
|
@channel.put %w(a)
|
52
69
|
@channel.put %w(b)
|
@@ -67,14 +84,6 @@ class IChannelUNIXTest < Test::Unit::TestCase
|
|
67
84
|
2.times { assert_equal %w(b), @channel.last_msg }
|
68
85
|
end
|
69
86
|
|
70
|
-
def test_put_and_get
|
71
|
-
pid = fork do
|
72
|
-
@channel.put %w(a b c)
|
73
|
-
end
|
74
|
-
Process.wait pid
|
75
|
-
assert_equal %w(a b c), @channel.get
|
76
|
-
end
|
77
|
-
|
78
87
|
def test_put_on_closed_channel
|
79
88
|
@channel.close
|
80
89
|
assert_raises IOError do
|
@@ -90,11 +99,8 @@ class IChannelUNIXTest < Test::Unit::TestCase
|
|
90
99
|
end
|
91
100
|
|
92
101
|
def test_queued_messages
|
93
|
-
|
94
|
-
|
95
|
-
@channel.put %w(b)
|
96
|
-
end
|
97
|
-
Process.wait pid
|
102
|
+
@channel.put %w(a)
|
103
|
+
@channel.put %w(b)
|
98
104
|
assert_equal %w(a), @channel.get
|
99
105
|
assert_equal %w(b), @channel.get
|
100
106
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ichannel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.1.
|
4
|
+
version: 6.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-05 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! "A modern and easy-to-use interprocess communication \n primitive."
|
15
15
|
email:
|
@@ -51,7 +51,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
51
|
version: '0'
|
52
52
|
segments:
|
53
53
|
- 0
|
54
|
-
hash:
|
54
|
+
hash: -277858576396614172
|
55
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
56
|
none: false
|
57
57
|
requirements:
|
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
60
|
version: '0'
|
61
61
|
segments:
|
62
62
|
- 0
|
63
|
-
hash:
|
63
|
+
hash: -277858576396614172
|
64
64
|
requirements: []
|
65
65
|
rubyforge_project:
|
66
66
|
rubygems_version: 1.8.23
|