msgr 0.11.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71ef2eda13a664e9afb9af7ca995ef2b1f47a4bb
4
- data.tar.gz: 0c5acbbdccb82657f36347ccc0c4e47c8fc50207
3
+ metadata.gz: cd577dc14c3fb4e5bfc6786ba513a5f5902a15de
4
+ data.tar.gz: e4e5782f2e8cad01a34cb542b9c70bf1a0366dae
5
5
  SHA512:
6
- metadata.gz: ff8f5b6f5d9ac58e403a43aed0c4488b24742acfb674acf669f7524b6d9257ac8bb515b9a92bc31f45e772cf7b3eb114b1ccf7fa767e9fd592f524ddde83ed57
7
- data.tar.gz: 0b4e3c3272fd2c954085ac7b3cad5d5d2174bcba7b6cbced32bb20280df0a1b84e8b16cc39e05b610bc6533e71a272d619f3a3fc78b03e61c6d21c7e9acfa1d7
6
+ metadata.gz: aef657496482095e8dc3d24d65803a36b190f7c48104d998433b41f057a5dbc508905b39f54a92cf12fa77eb85e269e5ae45b46c5e1163cdbfcd0ac9616b15a7
7
+ data.tar.gz: 88e1331b089dfa0e9e90dd7f24493ac8e4f2f151edb9865116bb68f2e114b24fc6dc9e8cee10df877203212b6f9e4cfd97f9c4a26c9fe7c0c969edf507233b52
data/lib/msgr/binding.rb CHANGED
@@ -17,7 +17,7 @@ module Msgr
17
17
  queue.bind connection.exchange, routing_key: key
18
18
  end
19
19
 
20
- @subscription = queue.subscribe(ack: true) do |*args|
20
+ @subscription = queue.subscribe(manual_ack: true) do |*args|
21
21
  begin
22
22
  dispatcher.call Message.new(connection, *args, route)
23
23
  rescue => err
data/lib/msgr/client.rb CHANGED
@@ -74,7 +74,7 @@ module Msgr
74
74
  def publish(payload, opts = {})
75
75
  mutex.synchronize do
76
76
  check_process!
77
- connection.publish payload, opts
77
+ sync_publish payload, opts
78
78
  end
79
79
  end
80
80
 
@@ -94,6 +94,22 @@ module Msgr
94
94
  end
95
95
 
96
96
  private
97
+
98
+ def sync_publish(payload, opts)
99
+ begin
100
+ payload = MultiJson.dump(payload)
101
+ opts[:content_type] ||= 'application/json'
102
+ rescue
103
+ opts[:content_type] ||= 'application/text'
104
+ end
105
+
106
+ sync_publish_message payload.to_s, opts
107
+ end
108
+
109
+ def sync_publish_message(message, opts)
110
+ connection.publish message, opts
111
+ end
112
+
97
113
  def mutex
98
114
  @mutex
99
115
  end
@@ -20,15 +20,10 @@ module Msgr
20
20
  bindings.any?
21
21
  end
22
22
 
23
- def publish(payload, opts = {})
23
+ def publish(message, opts = {})
24
24
  opts[:routing_key] = opts.delete(:to) if opts[:to]
25
25
 
26
- begin
27
- payload = MultiJson.dump(payload)
28
- exchange.publish payload, opts.merge(persistent: true, content_type: 'application/json')
29
- rescue => error
30
- exchange.publish payload.to_s, opts.merge(persistent: true, content_type: 'application/text')
31
- end
26
+ exchange.publish message.to_s, opts.merge(persistent: true)
32
27
 
33
28
  log(:debug) { "Published message to #{opts[:routing_key]}" }
34
29
  end
@@ -42,7 +37,11 @@ module Msgr
42
37
  end
43
38
 
44
39
  def channel
45
- @channel ||= connection.create_channel
40
+ @channel ||= begin
41
+ channel = connection.create_channel
42
+ channel.prefetch 1
43
+ channel
44
+ end
46
45
  end
47
46
 
48
47
  def release
@@ -1,4 +1,4 @@
1
- require 'concurrent/cached_thread_pool'
1
+ require 'concurrent'
2
2
 
3
3
  module Msgr
4
4
 
data/lib/msgr/version.rb CHANGED
@@ -2,7 +2,7 @@ module Msgr
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 11
5
- PATCH = 0
5
+ PATCH = 1
6
6
  STAGE = nil
7
7
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.')
8
8
 
data/msgr.gemspec CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_dependency 'activesupport'
22
- spec.add_dependency 'bunny', '~> 1.0'
23
- spec.add_dependency 'concurrent-ruby', '~> 0.5.0'
22
+ spec.add_dependency 'bunny', '~> 1.5'
23
+ spec.add_dependency 'concurrent-ruby', '~> 0.7.0'
24
24
  spec.add_dependency 'multi_json'
25
25
 
26
26
  spec.add_development_dependency 'bundler', '~> 1.3'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-03 00:00:00.000000000 Z
11
+ date: 2014-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '1.5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '1.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: concurrent-ruby
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.5.0
47
+ version: 0.7.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.5.0
54
+ version: 0.7.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: multi_json
57
57
  requirement: !ruby/object:Gem::Requirement