stomp_actors 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/lib/stomp_actors/client.rb +2 -24
- data/lib/stomp_actors/consumer.rb +3 -3
- data/lib/stomp_actors/producer.rb +1 -1
- data/lib/stomp_actors/version.rb +1 -1
- data/lib/stomp_actors.rb +2 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/stomp_actors/client_spec.rb +10 -5
- data/spec/stomp_actors/consumer_spec.rb +8 -3
- data/spec/stomp_actors/producer_spec.rb +5 -2
- data/stomp_actors.gemspec +2 -2
- metadata +7 -6
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/lib/stomp_actors/client.rb
CHANGED
@@ -16,34 +16,12 @@ module StompActors
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def connect
|
19
|
-
@client =
|
20
|
-
|
21
|
-
me = current_actor
|
22
|
-
|
23
|
-
@client.on_connection_closed do |_, _, msg|
|
24
|
-
me.async.connection_closed(msg)
|
25
|
-
end
|
26
|
-
|
27
|
-
@client.on_error do |e, *_|
|
28
|
-
me.async.broker_error(e)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def connection_closed(msg)
|
33
|
-
unless @disconnecting
|
34
|
-
error "Connection closed: #{msg}" if respond_to?(:error)
|
35
|
-
raise DisconnectionError.new(msg)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def broker_error(e)
|
40
|
-
error("Broker error: #{e.inspect}") if respond_to?(:error)
|
41
|
-
raise BrokerError.new(e[:message])
|
19
|
+
@client = Stomp::Client.new(connect_opts)
|
42
20
|
end
|
43
21
|
|
44
22
|
def disconnect
|
45
23
|
@disconnecting = true
|
46
|
-
@client.
|
24
|
+
@client.close if @client && @client.open?
|
47
25
|
end
|
48
26
|
|
49
27
|
end
|
@@ -21,7 +21,7 @@ module StompActors
|
|
21
21
|
def subscribe
|
22
22
|
me = current_actor
|
23
23
|
|
24
|
-
|
24
|
+
client.subscribe(queue, subscribe_opts) do |msg|
|
25
25
|
me.receive(msg)
|
26
26
|
end
|
27
27
|
end
|
@@ -31,7 +31,7 @@ module StompActors
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def ack(msg)
|
34
|
-
client.
|
34
|
+
client.acknowledge(msg)
|
35
35
|
end
|
36
36
|
|
37
37
|
def cleanup
|
@@ -40,7 +40,7 @@ module StompActors
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def unsubscribe
|
43
|
-
client.unsubscribe(
|
43
|
+
client.unsubscribe(queue)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
data/lib/stomp_actors/version.rb
CHANGED
data/lib/stomp_actors.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -5,15 +5,21 @@ describe StompActors::Client do
|
|
5
5
|
let(:port) { 61623 }
|
6
6
|
|
7
7
|
before do
|
8
|
+
|
8
9
|
class MyActor
|
9
10
|
include Celluloid
|
10
11
|
include StompActors::Client
|
11
12
|
|
12
|
-
def
|
13
|
-
|
13
|
+
def connect_opts
|
14
|
+
{
|
15
|
+
hosts: [{ host: '127.0.0.1', port: 61623 }]
|
16
|
+
}
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
20
|
+
Celluloid.shutdown
|
21
|
+
Celluloid.boot
|
22
|
+
|
17
23
|
@server_thread = StompDroid::Server.start(host, port)
|
18
24
|
sleep 0.1 # let start
|
19
25
|
end
|
@@ -26,11 +32,10 @@ describe StompActors::Client do
|
|
26
32
|
actor = MyActor.new
|
27
33
|
|
28
34
|
actor.connect
|
29
|
-
actor.client.
|
35
|
+
actor.client.open?.should be_true
|
30
36
|
|
31
37
|
actor.disconnect
|
32
|
-
actor.client.
|
38
|
+
actor.client.open?.should be_false
|
33
39
|
end
|
34
40
|
|
35
|
-
pending "should handle errors"
|
36
41
|
end
|
@@ -17,8 +17,10 @@ describe StompActors::Consumer do
|
|
17
17
|
super()
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
|
20
|
+
def connect_opts
|
21
|
+
{
|
22
|
+
hosts: [{ host: @host, port: @port}]
|
23
|
+
}
|
22
24
|
end
|
23
25
|
|
24
26
|
def receive(msg)
|
@@ -29,6 +31,9 @@ describe StompActors::Consumer do
|
|
29
31
|
def do_something; end
|
30
32
|
end
|
31
33
|
|
34
|
+
Celluloid.shutdown
|
35
|
+
Celluloid.boot
|
36
|
+
|
32
37
|
@server_thread = StompDroid::Server.start(host, port, queue_name: queue, message: msg)
|
33
38
|
sleep 0.1 # let start
|
34
39
|
end
|
@@ -49,6 +54,6 @@ describe StompActors::Consumer do
|
|
49
54
|
sleep 0.1
|
50
55
|
consumer.terminate
|
51
56
|
sleep 0.1
|
52
|
-
expect(client.
|
57
|
+
expect(client.open?).to be_false
|
53
58
|
end
|
54
59
|
end
|
@@ -8,14 +8,17 @@ describe StompActors::Producer do
|
|
8
8
|
|
9
9
|
before do
|
10
10
|
class MyProducer < StompActors::Producer
|
11
|
-
def
|
12
|
-
"
|
11
|
+
def connect_opts
|
12
|
+
{ hosts: [{ host: "127.0.0.1", port: 61623 }] }
|
13
13
|
end
|
14
14
|
def queue
|
15
15
|
'/queue/foo'
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
Celluloid.shutdown
|
20
|
+
Celluloid.boot
|
21
|
+
|
19
22
|
@server_thread = StompDroid::Server.start(host, port, queue_name: queue, sent_message_dir: message_dir)
|
20
23
|
sleep 0.1 # let start
|
21
24
|
end
|
data/stomp_actors.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Emilien Taque"]
|
10
10
|
spec.email = ["e.taque@alphalink.fr"]
|
11
11
|
spec.description = %q{Celluloid actors for Stomp}
|
12
|
-
spec.summary = %q{Build Stomp consumers and publishers with Celluloid actors framework and
|
12
|
+
spec.summary = %q{Build Stomp consumers and publishers with Celluloid actors framework and stomp lib.}
|
13
13
|
spec.homepage = ""
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -25,5 +25,5 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency 'pry'
|
26
26
|
|
27
27
|
spec.add_runtime_dependency 'celluloid', '~> 0.14'
|
28
|
-
spec.add_runtime_dependency '
|
28
|
+
spec.add_runtime_dependency 'stomp', '~> 1.2.9'
|
29
29
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stomp_actors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.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-
|
12
|
+
date: 2013-06-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -108,13 +108,13 @@ dependencies:
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0.14'
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
|
-
name:
|
111
|
+
name: stomp
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
113
113
|
none: false
|
114
114
|
requirements:
|
115
115
|
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 1.2.9
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
requirements:
|
123
123
|
- - ~>
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
125
|
+
version: 1.2.9
|
126
126
|
description: Celluloid actors for Stomp
|
127
127
|
email:
|
128
128
|
- e.taque@alphalink.fr
|
@@ -131,6 +131,7 @@ extensions: []
|
|
131
131
|
extra_rdoc_files: []
|
132
132
|
files:
|
133
133
|
- .gitignore
|
134
|
+
- .rspec
|
134
135
|
- Gemfile
|
135
136
|
- LICENSE.txt
|
136
137
|
- README.md
|
@@ -170,7 +171,7 @@ rubygems_version: 1.8.25
|
|
170
171
|
signing_key:
|
171
172
|
specification_version: 3
|
172
173
|
summary: Build Stomp consumers and publishers with Celluloid actors framework and
|
173
|
-
|
174
|
+
stomp lib.
|
174
175
|
test_files:
|
175
176
|
- spec/spec_helper.rb
|
176
177
|
- spec/stomp_actors/client_spec.rb
|