em-posixmq 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/em-posixmq.rb +11 -9
- data/lib/em-posixmq/errors.rb +5 -0
- data/lib/em-posixmq/version.rb +1 -1
- metadata +4 -3
data/lib/em-posixmq.rb
CHANGED
@@ -2,12 +2,13 @@ require "eventmachine"
|
|
2
2
|
require "posix_mq"
|
3
3
|
|
4
4
|
require "em-posixmq/version"
|
5
|
+
require "em-posixmq/errors"
|
5
6
|
|
6
7
|
|
7
8
|
module EventMachine::PosixMQ
|
8
9
|
|
9
|
-
class Watcher < EM::Connection
|
10
|
-
def initialize
|
10
|
+
class Watcher < ::EM::Connection
|
11
|
+
def initialize posix_mq
|
11
12
|
@posix_mq = posix_mq
|
12
13
|
@posix_mq.nonblock = true
|
13
14
|
end
|
@@ -18,18 +19,19 @@ module EventMachine::PosixMQ
|
|
18
19
|
receive_message message, priority if message
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
# This method must be defined in the user's class inherinting this one.
|
23
|
+
def receive_message message, priority
|
24
|
+
puts "EM::PosixMQ::Watcher#receive_message #{message.inspect}, #{priority.inspect}"
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
|
-
def self.run
|
27
|
-
raise Error, "EventMachine is not running" unless EM.reactor_running?
|
28
|
+
def self.run posix_mq, handler
|
29
|
+
raise ::EM::PosixMQ::Error, "EventMachine is not running" unless ::EM.reactor_running?
|
28
30
|
|
29
|
-
raise Error, "`posix_mq' argument must be a POSIX_MQ instance" unless
|
30
|
-
posix_mq.is_a? POSIX_MQ
|
31
|
+
raise ::EM::PosixMQ::Error, "`posix_mq' argument must be a POSIX_MQ instance" unless
|
32
|
+
posix_mq.is_a? ::POSIX_MQ
|
31
33
|
|
32
|
-
conn = EM.watch posix_mq.to_io, handler, posix_mq
|
34
|
+
conn = ::EM.watch posix_mq.to_io, handler, posix_mq
|
33
35
|
conn.notify_readable = true
|
34
36
|
|
35
37
|
return conn
|
data/lib/em-posixmq/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 2
|
9
|
+
version: 0.2.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- "I\xC3\xB1aki Baz Castillo"
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-12-02 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -56,6 +56,7 @@ extra_rdoc_files: []
|
|
56
56
|
files:
|
57
57
|
- lib/em-posixmq.rb
|
58
58
|
- lib/em-posixmq/version.rb
|
59
|
+
- lib/em-posixmq/errors.rb
|
59
60
|
- test/test-em-posixmq-client.rb
|
60
61
|
- test/test-em-posixmq-server.rb
|
61
62
|
has_rdoc: true
|