ichannel 5.1.1 → 5.1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +6 -2
- data/ChangeLog.txt +4 -0
- data/README.md +26 -47
- data/lib/ichannel/version.rb +1 -1
- data/lib/ichannel.rb +0 -1
- data/test/ichannel_class_test.rb +5 -4
- metadata +4 -4
data/.travis.yml
CHANGED
data/ChangeLog.txt
CHANGED
data/README.md
CHANGED
@@ -1,31 +1,33 @@
|
|
1
1
|
__OVERVIEW__
|
2
2
|
|
3
3
|
|
4
|
-
| Project |
|
4
|
+
| Project | ichannel
|
5
5
|
|:----------------|:--------------------------------------------------
|
6
6
|
| Homepage | https://github.com/robgleeson/ichannel
|
7
|
-
| Documentation | http://rubydoc.info/
|
7
|
+
| Documentation | http://rubydoc.info/github/robgleeson/ichannel/frames
|
8
8
|
| CI | [](https://travis-ci.org/robgleeson/ichannel)
|
9
9
|
| Author | Robert Gleeson
|
10
10
|
|
11
11
|
|
12
12
|
__DESCRIPTION__
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
ichannel simplifies interprocess communication by providing a bi-directional
|
15
|
+
channel that can transport ruby objects between processes on the same machine.
|
16
|
+
All communication on a channel occurs on a streamed UNIXSocket that a channel
|
17
|
+
uses to queues its messages (ruby objects), and also to ensure that messages
|
18
|
+
are received in the order they are sent.
|
19
|
+
|
20
|
+
In order to transport ruby objects through a channel the objects are serialized
|
21
|
+
before a write and deserialized after a read. The choice of serializer is left
|
22
|
+
up to you. A serializer can be any object that implements `dump` and
|
23
|
+
`load` -- two methods that are usually implemented by serializers written in
|
24
|
+
ruby.
|
21
25
|
|
22
26
|
__EXAMPLES__
|
23
27
|
|
24
28
|
__1.__
|
25
29
|
|
26
|
-
|
27
|
-
The serializer of choice is `Marshal` but it could just as easily be `JSON` or
|
28
|
-
`YAML`.
|
30
|
+
A demo of how to pass ruby objects through a channel and also between processes:
|
29
31
|
|
30
32
|
```ruby
|
31
33
|
channel = IChannel.new Marshal
|
@@ -38,52 +40,24 @@ channel.get # => Fixnum
|
|
38
40
|
channel.get # => 'Hello!'
|
39
41
|
```
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
To send Ruby objects between processes they have to be serialized, but on the
|
44
|
-
bright side the number of serializers to choose from is vast. Marshal, JSON, &
|
45
|
-
YAML are supported out of the box to name a few but adding support for other
|
46
|
-
serializers is a trivial amount of work.
|
43
|
+
__2.__
|
47
44
|
|
48
|
-
|
45
|
+
MessagePack doesn't implement `dump` or `load` but a wrapper can be easily
|
46
|
+
written:
|
49
47
|
|
50
48
|
```ruby
|
51
|
-
|
52
|
-
require 'msgpack'
|
53
|
-
serializer = Class.new do
|
49
|
+
module MyMessagePack
|
54
50
|
def self.dump(msg)
|
55
|
-
MessagePack.pack
|
51
|
+
MessagePack.pack(msg)
|
56
52
|
end
|
57
53
|
|
58
54
|
def self.load(msg)
|
59
|
-
MessagePack.unpack
|
55
|
+
MessagePack.unpack(msg)
|
60
56
|
end
|
61
57
|
end
|
62
|
-
channel = IChannel.new
|
58
|
+
channel = IChannel.new MyMessagePack
|
63
59
|
```
|
64
60
|
|
65
|
-
As you can see above as long as the serializer responds to `.dump` & `.load` it
|
66
|
-
can be passed as a serializer to IChannel.
|
67
|
-
|
68
|
-
__REAL WORLD EXAMPLES__
|
69
|
-
|
70
|
-
I am using IChannel in a couple of my own personal projects:
|
71
|
-
|
72
|
-
- [IProcess](https://github.com/robgleeson/iprocess)
|
73
|
-
Provides a number of abstractions on top of spawning subprocesses and
|
74
|
-
interprocess communication. IChannel was born inside IProcess but later
|
75
|
-
extracted into its own project when I realised it could be useful on its
|
76
|
-
own.
|
77
|
-
|
78
|
-
- [xpool](https://github.com/robgleeson/xpool)
|
79
|
-
A lightweight UNIX(X) process pool implementation.
|
80
|
-
|
81
|
-
|
82
|
-
Other people have started to write code on top of ichannel, too:
|
83
|
-
|
84
|
-
- [ifuture](https://github.com/Havenwood/ifuture)
|
85
|
-
An implementation of Futures for Ruby using process forks and ichannel.
|
86
|
-
|
87
61
|
__PLATFORM SUPPORT__
|
88
62
|
|
89
63
|
_supported_
|
@@ -101,6 +75,11 @@ __INSTALL__
|
|
101
75
|
|
102
76
|
$ gem install ichannel
|
103
77
|
|
78
|
+
__SEE ALSO__
|
79
|
+
|
80
|
+
- [ifuture](https://github.com/Havenwood/ifuture)
|
81
|
+
futures built on process forks and ichannel.
|
82
|
+
|
104
83
|
__LICENSE__
|
105
84
|
|
106
85
|
MIT. See LICENSE.txt.
|
data/lib/ichannel/version.rb
CHANGED
data/lib/ichannel.rb
CHANGED
data/test/ichannel_class_test.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
require_relative 'setup'
|
2
2
|
class IChannelTest < Test::Unit::TestCase
|
3
3
|
def setup
|
4
|
-
|
4
|
+
serializer = Object.const_get ENV["SERIALIZER"] || "Marshal"
|
5
|
+
@channel = IChannel.new serializer
|
5
6
|
end
|
6
7
|
|
7
8
|
def teardown
|
8
9
|
@channel.close
|
9
10
|
end
|
10
11
|
|
11
|
-
def test_put_and_get
|
12
|
+
def test_put_and_get
|
12
13
|
pid = fork do
|
13
14
|
@channel.put %w(a b c)
|
14
15
|
end
|
@@ -26,12 +27,12 @@ class IChannelTest < Test::Unit::TestCase
|
|
26
27
|
def test_get_on_closed_channel
|
27
28
|
@channel.close
|
28
29
|
assert_raises IOError do
|
29
|
-
@channel.
|
30
|
+
@channel.get
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
34
|
def test_queued_messages
|
34
|
-
pid = fork do
|
35
|
+
pid = fork do
|
35
36
|
@channel.put %w(a)
|
36
37
|
@channel.put %w(b)
|
37
38
|
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: 5.1.1
|
4
|
+
version: 5.1.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-
|
12
|
+
date: 2013-03-18 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! "A modern and easy-to-use interprocess communication \n primitive."
|
15
15
|
email:
|
@@ -46,7 +46,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
46
46
|
version: '0'
|
47
47
|
segments:
|
48
48
|
- 0
|
49
|
-
hash: -
|
49
|
+
hash: -2186920518720444736
|
50
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
@@ -55,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
55
|
version: '0'
|
56
56
|
segments:
|
57
57
|
- 0
|
58
|
-
hash: -
|
58
|
+
hash: -2186920518720444736
|
59
59
|
requirements: []
|
60
60
|
rubyforge_project:
|
61
61
|
rubygems_version: 1.8.23
|