em-posixmq 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/em-posixmq.rb +9 -9
- data/lib/em-posixmq/version.rb +5 -0
- data/test/test-em-posixmq-client.rb +3 -1
- metadata +39 -59
data/lib/em-posixmq.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require "eventmachine"
|
2
2
|
require "posix_mq"
|
3
3
|
|
4
|
+
require "em-posixmq/version"
|
5
|
+
|
4
6
|
|
5
7
|
module EventMachine::PosixMQ
|
6
8
|
|
@@ -11,14 +13,13 @@ module EventMachine::PosixMQ
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def notify_readable
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
rescue Errno::EAGAIN
|
18
|
-
end
|
16
|
+
# POSIX_MQ#tryreceive returns nil in case there is nothing to read.
|
17
|
+
message, priority = @posix_mq.tryreceive
|
18
|
+
receive_message message, priority if message
|
19
19
|
end
|
20
20
|
|
21
21
|
def receive_message(message, priority)
|
22
|
+
# This method must be defined in the user's class inherinting this one.
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
@@ -28,11 +29,10 @@ module EventMachine::PosixMQ
|
|
28
29
|
raise Error, "`posix_mq' argument must be a POSIX_MQ instance" unless
|
29
30
|
posix_mq.is_a? POSIX_MQ
|
30
31
|
|
31
|
-
EM.watch posix_mq.to_io, handler, posix_mq
|
32
|
-
|
33
|
-
end
|
32
|
+
conn = EM.watch posix_mq.to_io, handler, posix_mq
|
33
|
+
conn.notify_readable = true
|
34
34
|
|
35
|
-
|
35
|
+
return conn
|
36
36
|
end
|
37
37
|
|
38
38
|
end
|
@@ -12,7 +12,9 @@ while true do
|
|
12
12
|
priority = SecureRandom.random_number 9
|
13
13
|
|
14
14
|
puts "sending message '#{message}' with priority #{priority} to the queue..."
|
15
|
-
posix_mq.
|
15
|
+
unless posix_mq.trysend message, priority
|
16
|
+
puts "WARN: cannot write '#{message}' into the queue (full)"
|
17
|
+
end
|
16
18
|
|
17
19
|
sleep SecureRandom.random_number
|
18
20
|
end
|
metadata
CHANGED
@@ -1,93 +1,73 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: em-posixmq
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
version: 0.1.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
12
|
-
-
|
7
|
+
authors:
|
8
|
+
- Iñaki Baz Castillo
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
date: 2011-02-20 00:00:00 +01:00
|
12
|
+
date: 2011-03-01 00:00:00.000000000 +01:00
|
18
13
|
default_executable:
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
21
16
|
name: eventmachine
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: &20625640 !ruby/object:Gem::Requirement
|
24
18
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 0
|
30
|
-
version: "0"
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
31
23
|
type: :runtime
|
32
|
-
version_requirements: *id001
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: posix_mq
|
35
24
|
prerelease: false
|
36
|
-
|
25
|
+
version_requirements: *20625640
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: posix_mq
|
28
|
+
requirement: &20664680 !ruby/object:Gem::Requirement
|
37
29
|
none: false
|
38
|
-
requirements:
|
39
|
-
- -
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
- 0
|
43
|
-
version: "0"
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.0
|
44
34
|
type: :runtime
|
45
|
-
|
46
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *20664680
|
37
|
+
description: em-posixmq integrates posix_mq Ruby library into the EventMachine reactor
|
38
|
+
allowing asynchronous reading from a POSIX message queue
|
47
39
|
email: ibc@aliax.net
|
48
40
|
executables: []
|
49
|
-
|
50
41
|
extensions: []
|
51
|
-
|
52
42
|
extra_rdoc_files: []
|
53
|
-
|
54
|
-
files:
|
43
|
+
files:
|
55
44
|
- lib/em-posixmq.rb
|
45
|
+
- lib/em-posixmq/version.rb
|
56
46
|
- test/test-em-posixmq-client.rb
|
57
47
|
- test/test-em-posixmq-server.rb
|
58
48
|
has_rdoc: true
|
59
49
|
homepage: https://github.com/ibc/em-posixmq
|
60
50
|
licenses: []
|
61
|
-
|
62
51
|
post_install_message:
|
63
52
|
rdoc_options: []
|
64
|
-
|
65
|
-
require_paths:
|
53
|
+
require_paths:
|
66
54
|
- lib
|
67
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
56
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
segments:
|
73
|
-
- 1
|
74
|
-
- 8
|
75
|
-
- 7
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
76
60
|
version: 1.8.7
|
77
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
62
|
none: false
|
79
|
-
requirements:
|
80
|
-
- -
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
|
83
|
-
- 0
|
84
|
-
version: "0"
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
85
67
|
requirements: []
|
86
|
-
|
87
68
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.3
|
69
|
+
rubygems_version: 1.5.3
|
89
70
|
signing_key:
|
90
71
|
specification_version: 3
|
91
72
|
summary: posix_mq library integrated into EventMachine reactor for asynchronous reading
|
92
73
|
test_files: []
|
93
|
-
|