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 ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -16,34 +16,12 @@ module StompActors
16
16
  end
17
17
 
18
18
  def connect
19
- @client = OnStomp.open(uri)
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.disconnect if @client && @client.connected?
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
- @subscription_id = client.subscribe(queue, subscribe_opts) do |msg|
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.ack(msg)
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(@subscription_id) if @subscription_id
43
+ client.unsubscribe(queue)
44
44
  end
45
45
  end
46
46
  end
@@ -12,7 +12,7 @@ module StompActors
12
12
  end
13
13
 
14
14
  def emit(msg, opts = {})
15
- client.send(queue, msg, opts)
15
+ client.publish(queue, msg, opts)
16
16
  end
17
17
 
18
18
  end
@@ -1,3 +1,3 @@
1
1
  module StompActors
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/stomp_actors.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'stomp'
2
+
1
3
  require "stomp_actors/version"
2
4
  require "stomp_actors/client"
3
5
  require "stomp_actors/producer"
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,7 @@ require 'bundler'
2
2
 
3
3
  require 'celluloid'
4
4
  require 'stomp_droid'
5
- require 'onstomp'
5
+ require 'stomp'
6
6
  require 'pry'
7
7
 
8
8
  require 'stomp_actors'
@@ -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 uri
13
- "stomp://127.0.0.1:61623"
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.connected?.should be_true
35
+ actor.client.open?.should be_true
30
36
 
31
37
  actor.disconnect
32
- actor.client.connected?.should be_false
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 uri
21
- "stomp://#{@host}:#{@port}"
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.connected?).to be_false
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 uri
12
- "stomp://127.0.0.1:61623"
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 OnStomp lib.}
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 'onstomp', '~> 1.0'
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.1.2
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-05-21 00:00:00.000000000 Z
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: onstomp
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: '1.0'
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: '1.0'
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
- OnStomp lib.
174
+ stomp lib.
174
175
  test_files:
175
176
  - spec/spec_helper.rb
176
177
  - spec/stomp_actors/client_spec.rb