ichannel 5.1.1 → 5.1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,9 +1,13 @@
1
1
  rvm:
2
2
  - 1.9.2
3
3
  - 1.9.3
4
+ - 2.0.0
4
5
  - ruby-head
5
- # UNIXSocket#recvmsg iz not implemented on Rubinius yet.
6
- # - rbx-19mode
6
+
7
+ env:
8
+ - SERIALIZER=YAML
9
+ - SERIALIZER=Marshal
10
+ - SERIALIZER=JSON
7
11
 
8
12
  notifications:
9
13
  email: true
data/ChangeLog.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == v5.1.1.1
2
+ * doc improvements
3
+ a set of doc improvements
4
+
1
5
  == v5.1.1
2
6
  * Change socket type to use TCP.
3
7
  The use of UDP could result in bugs because of its unordered nature.
data/README.md CHANGED
@@ -1,31 +1,33 @@
1
1
  __OVERVIEW__
2
2
 
3
3
 
4
- | Project | IChannel
4
+ | Project | ichannel
5
5
  |:----------------|:--------------------------------------------------
6
6
  | Homepage | https://github.com/robgleeson/ichannel
7
- | Documentation | http://rubydoc.info/gems/ichannel/frames
7
+ | Documentation | http://rubydoc.info/github/robgleeson/ichannel/frames
8
8
  | CI | [![Build Status](https://travis-ci.org/robgleeson/ichannel.png)](https://travis-ci.org/robgleeson/ichannel)
9
9
  | Author | Robert Gleeson
10
10
 
11
11
 
12
12
  __DESCRIPTION__
13
13
 
14
- A modern, flexible & easy to use interprocess communication(IPC) primitive. The
15
- basic premise is that you can "put" and "get" Ruby objects to/from a channel.
16
- This works across any Ruby process & its subprocesses, though, which is why it
17
- can be useful. You could describe putting and getting objects to/from the channel
18
- as message passing but the message could potentially be any Ruby object,
19
- although I think sending small messages(as a Hash) works very well for most
20
- scenarios.
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
- The first example shows off how you'd pass Ruby objects through a channel.
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
- __SERIALIZERS__
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
- For example, here is a MessagePack serializer you could use:
45
+ MessagePack doesn't implement `dump` or `load` but a wrapper can be easily
46
+ written:
49
47
 
50
48
  ```ruby
51
- require 'ichannel'
52
- require 'msgpack'
53
- serializer = Class.new do
49
+ module MyMessagePack
54
50
  def self.dump(msg)
55
- MessagePack.pack msg
51
+ MessagePack.pack(msg)
56
52
  end
57
53
 
58
54
  def self.load(msg)
59
- MessagePack.unpack msg
55
+ MessagePack.unpack(msg)
60
56
  end
61
57
  end
62
- channel = IChannel.new serializer
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.
@@ -1,3 +1,3 @@
1
1
  class IChannel
2
- VERSION = "5.1.1"
2
+ VERSION = "5.1.1.1"
3
3
  end
data/lib/ichannel.rb CHANGED
@@ -26,7 +26,6 @@ class IChannel
26
26
  #
27
27
  # @return [Boolean]
28
28
  # Returns true when the channel has been closed.
29
- # Returns nil when the channel is already closed.
30
29
  #
31
30
  def close
32
31
  unless closed?
@@ -1,14 +1,15 @@
1
1
  require_relative 'setup'
2
2
  class IChannelTest < Test::Unit::TestCase
3
3
  def setup
4
- @channel = IChannel.new [YAML, Marshal, JSON].sample
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.put %w(b)
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-01-12 00:00:00.000000000 Z
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: -4510016947679308105
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: -4510016947679308105
58
+ hash: -2186920518720444736
59
59
  requirements: []
60
60
  rubyforge_project:
61
61
  rubygems_version: 1.8.23