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 +4 -4
- data/lib/msgr/binding.rb +1 -1
- data/lib/msgr/client.rb +17 -1
- data/lib/msgr/connection.rb +7 -8
- data/lib/msgr/dispatcher.rb +1 -1
- data/lib/msgr/version.rb +1 -1
- data/msgr.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd577dc14c3fb4e5bfc6786ba513a5f5902a15de
|
4
|
+
data.tar.gz: e4e5782f2e8cad01a34cb542b9c70bf1a0366dae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
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
|
-
|
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
|
data/lib/msgr/connection.rb
CHANGED
@@ -20,15 +20,10 @@ module Msgr
|
|
20
20
|
bindings.any?
|
21
21
|
end
|
22
22
|
|
23
|
-
def publish(
|
23
|
+
def publish(message, opts = {})
|
24
24
|
opts[:routing_key] = opts.delete(:to) if opts[:to]
|
25
25
|
|
26
|
-
|
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 ||=
|
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
|
data/lib/msgr/dispatcher.rb
CHANGED
data/lib/msgr/version.rb
CHANGED
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.
|
23
|
-
spec.add_dependency 'concurrent-ruby', '~> 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.
|
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-
|
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.
|
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.
|
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.
|
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.
|
54
|
+
version: 0.7.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: multi_json
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|