ichannel 7.1.0 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +4 -5
- data/ChangeLog.txt +12 -0
- data/Gemfile +3 -0
- data/README.md +0 -9
- data/lib/ichannel/redis.rb +7 -12
- data/lib/ichannel/unix_socket.rb +6 -9
- data/lib/ichannel/version.rb +1 -1
- data/lib/ichannel.rb +1 -1
- data/test/ichannel_redis_test.rb +10 -8
- data/test/ichannel_unix_test.rb +1 -1
- data/test/setup.rb +2 -1
- data/test/uniform_ichannel_test.rb +2 -2
- metadata +4 -4
data/.travis.yml
CHANGED
@@ -2,14 +2,13 @@ rvm:
|
|
2
2
|
- 1.9.2
|
3
3
|
- 1.9.3
|
4
4
|
- 2.0.0
|
5
|
-
# - ruby-head
|
6
5
|
- rbx-19mode
|
7
|
-
#
|
6
|
+
# - ruby-head
|
8
7
|
|
9
8
|
env:
|
10
|
-
- SERIALIZER=YAML
|
11
|
-
- SERIALIZER=Marshal
|
12
|
-
- SERIALIZER=JSON
|
9
|
+
- REDIS=1 SERIALIZER=YAML
|
10
|
+
- REDIS=1 SERIALIZER=Marshal
|
11
|
+
- REDIS=1 SERIALIZER=JSON
|
13
12
|
|
14
13
|
services:
|
15
14
|
- redis-server
|
data/ChangeLog.txt
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
== v8.0.0
|
2
|
+
- Redis#write! does not time out.
|
3
|
+
A write to redis is not wrapped in Timeout.timeout() anymore
|
4
|
+
and cannot be timed out. The timeout argument is a no-op.
|
5
|
+
|
6
|
+
- Add IChannel::TimeoutError
|
7
|
+
Redis#get!, UNIXSocket#get!, UNIXSocket#write! raise
|
8
|
+
IChannel::TimeoutError instead of Timeout::Error.
|
9
|
+
|
10
|
+
- Remove all use of timeout.rb from lib/
|
11
|
+
'timeout' from the standard library is retired from ichannel.
|
12
|
+
|
1
13
|
== v7.1.0
|
2
14
|
- Redis#last_msg, UNIXSocket#last_msg return last read value
|
3
15
|
after a channel has been closed.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -101,15 +101,6 @@ _supported_
|
|
101
101
|
|
102
102
|
* CRuby (1.9+)
|
103
103
|
* Rubinius (1.9+)
|
104
|
-
* JRuby (1.9+ - some tests skipped)
|
105
|
-
JRuby is supported and passes the test suite but it skips any
|
106
|
-
tests(three/four) that invoke Kernel#fork. The other tests pass
|
107
|
-
on jruby, and those tests cover unix sockets/redis.
|
108
|
-
|
109
|
-
_unsupported_
|
110
|
-
|
111
|
-
* Any 1.8 implementation
|
112
|
-
* MacRuby
|
113
104
|
|
114
105
|
__INSTALL__
|
115
106
|
|
data/lib/ichannel/redis.rb
CHANGED
@@ -59,27 +59,22 @@ class IChannel::Redis
|
|
59
59
|
# Add an object to the channel.
|
60
60
|
#
|
61
61
|
# @param [Object] object
|
62
|
-
#
|
62
|
+
# An object to add.
|
63
63
|
#
|
64
64
|
# @param [Fixnum] timeout
|
65
|
-
#
|
65
|
+
# This argument is a no-op for a write to a redis channel.
|
66
66
|
#
|
67
67
|
# @raise [IOError]
|
68
68
|
# When the channel is closed.
|
69
69
|
#
|
70
|
-
# @raise [Timeout::Error]
|
71
|
-
# When the write does not complete in time.
|
72
|
-
#
|
73
70
|
# @return [void]
|
74
71
|
#
|
75
72
|
def write!(object, timeout = 0.1)
|
76
73
|
if closed?
|
77
74
|
raise IOError, 'The channel cannot be written to (closed)'
|
78
75
|
end
|
79
|
-
|
80
|
-
|
81
|
-
@redis.lpush @key, dump
|
82
|
-
end
|
76
|
+
dump = @serializer.dump object
|
77
|
+
@redis.lpush @key, dump
|
83
78
|
end
|
84
79
|
alias_method :put!, :write!
|
85
80
|
|
@@ -99,12 +94,12 @@ class IChannel::Redis
|
|
99
94
|
|
100
95
|
#
|
101
96
|
# @param [Fixnum] timeout
|
102
|
-
# The number of seconds (as an Integer) to wait
|
97
|
+
# The number of seconds (as an Integer) to wait for a read.
|
103
98
|
#
|
104
99
|
# @raise [IOError]
|
105
100
|
# When the channel is closed or empty.
|
106
101
|
#
|
107
|
-
# @raise [
|
102
|
+
# @raise [IChannel::TimeoutError]
|
108
103
|
# When _timeout_ seconds pass and the read has not completed.
|
109
104
|
#
|
110
105
|
# @return [Object]
|
@@ -118,7 +113,7 @@ class IChannel::Redis
|
|
118
113
|
if payload
|
119
114
|
@last_msg = @serializer.load(payload)
|
120
115
|
else
|
121
|
-
raise
|
116
|
+
raise IChannel::TimeoutError, "timeout on read after #{timeout} seconds"
|
122
117
|
end
|
123
118
|
end
|
124
119
|
alias_method :get!, :recv!
|
data/lib/ichannel/unix_socket.rb
CHANGED
@@ -47,7 +47,7 @@ module IChannel
|
|
47
47
|
# When the channel is closed.
|
48
48
|
#
|
49
49
|
# @param [Object] object
|
50
|
-
# An object to add
|
50
|
+
# An object to add.
|
51
51
|
#
|
52
52
|
def write(object)
|
53
53
|
write!(object, nil)
|
@@ -57,20 +57,17 @@ module IChannel
|
|
57
57
|
#
|
58
58
|
# Add an object to the channel.
|
59
59
|
#
|
60
|
-
# Unlike {#write}, which waits indefinitely until the channel becomes writable,
|
61
|
-
# this method will raise an IOError when _timeout_ seconds elapse and
|
62
|
-
# the channel remains unwritable.
|
63
|
-
#
|
64
60
|
# @param
|
65
61
|
# (see IChannel#write)
|
66
62
|
#
|
67
63
|
# @param [Numeric] timeout
|
68
64
|
# The number of seconds to wait for the channel to become writable.
|
69
65
|
#
|
70
|
-
# @raise
|
66
|
+
# @raise
|
67
|
+
# (see IChannel#write)
|
71
68
|
#
|
72
69
|
# @raise [IOError]
|
73
|
-
# When _timeout_ seconds elapse
|
70
|
+
# When _timeout_ seconds elapse and the channel cannot be written to.
|
74
71
|
#
|
75
72
|
def write!(object, timeout = 0.1)
|
76
73
|
if @writer.closed?
|
@@ -127,7 +124,7 @@ module IChannel
|
|
127
124
|
# @raise [IOError]
|
128
125
|
# (see IChannel#recv)
|
129
126
|
#
|
130
|
-
# @raise [
|
127
|
+
# @raise [IChannel::TimeoutError]
|
131
128
|
# When _timeout_ seconds elapse & the channel remains unreadable.
|
132
129
|
#
|
133
130
|
# @return [Object]
|
@@ -142,7 +139,7 @@ module IChannel
|
|
142
139
|
msg = readable[0].readline(SEP).chomp SEP
|
143
140
|
@last_msg = @serializer.load msg
|
144
141
|
else
|
145
|
-
raise
|
142
|
+
raise IChannel::TimeoutError, 'Time out on read (waited for %s second(s))' % [timeout]
|
146
143
|
end
|
147
144
|
end
|
148
145
|
alias_method :get!, :recv!
|
data/lib/ichannel/version.rb
CHANGED
data/lib/ichannel.rb
CHANGED
data/test/ichannel_redis_test.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
require_relative 'setup'
|
2
|
-
|
3
|
-
|
2
|
+
if ENV["REDIS"] != "1"
|
3
|
+
require "colorize"
|
4
|
+
warn "[WARNING] redis tests ignored. set REDIS=1 to test with redis.".red
|
5
|
+
testcase = Object
|
6
|
+
else
|
7
|
+
testcase = Test::Unit::TestCase
|
8
|
+
end
|
9
|
+
|
10
|
+
class IChannelRedisTest < testcase
|
11
|
+
# This includes the tests all channels should pass(redis and unix
|
4
12
|
# socket). Any tests specific to redis can go in this class.
|
5
13
|
include UniformIChannelTest
|
6
14
|
|
@@ -14,10 +22,4 @@ class IChannelRedisTest < Test::Unit::TestCase
|
|
14
22
|
@channel.instance_variable_get(:@redis).del(key)
|
15
23
|
@channel.close
|
16
24
|
end
|
17
|
-
|
18
|
-
def test_timeout_on_get
|
19
|
-
assert_raises Timeout::Error do
|
20
|
-
@channel.get! 1
|
21
|
-
end
|
22
|
-
end
|
23
25
|
end
|
data/test/ichannel_unix_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative "setup"
|
2
2
|
class IChannelTest < Test::Unit::TestCase
|
3
|
-
# This includes the tests all channels should pass(redis
|
3
|
+
# This includes the tests all channels should pass(redis and unix
|
4
4
|
# socket). Any tests specific to a unit socket can go in this class.
|
5
5
|
include UniformIChannelTest
|
6
6
|
|
data/test/setup.rb
CHANGED
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:
|
4
|
+
version: 8.0.0
|
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-08-
|
12
|
+
date: 2013-08-15 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: interprocess communication channel
|
15
15
|
email:
|
@@ -52,7 +52,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
52
|
version: '0'
|
53
53
|
segments:
|
54
54
|
- 0
|
55
|
-
hash:
|
55
|
+
hash: 3456216786864862770
|
56
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
61
|
version: '0'
|
62
62
|
segments:
|
63
63
|
- 0
|
64
|
-
hash:
|
64
|
+
hash: 3456216786864862770
|
65
65
|
requirements: []
|
66
66
|
rubyforge_project:
|
67
67
|
rubygems_version: 1.8.23
|