angie-core-api 0.7.2 → 0.7.4
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fac64928eb3f641a0b73a7eab0d7a459817ef4ac86ee2596ead6ccc64b17f849
|
4
|
+
data.tar.gz: 9d5adb924f95177afe92bbaee98ee998aedb714f1aaf69d2bff3f43eb2d85d99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 958e1747f8e70243f048d1fd8bdfe81423045cf1dd4d0a0e7cbe2fb2680c867e02b192f8c83e0b7efe719c201b95ff371e83e96c4d95b8926a80b9cf9f33e712
|
7
|
+
data.tar.gz: 35cb05a9b8c59537769786e5df772e64443e6087ba83dd59e43a566ad9777fa29e07c2375d4e8698cbe8c0cdf171978a40b033f1fb635e1ecad32d043562e7eb
|
@@ -36,14 +36,13 @@ module AngieCoreApi
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def self.connect
|
39
|
-
|
40
|
-
classes.each { |k| k.new }
|
39
|
+
classes.each { |k| k.new } if instance.connection&.connected?
|
41
40
|
end
|
42
41
|
|
43
42
|
def self.disconnect!
|
44
|
-
|
43
|
+
instance.connection.close
|
45
44
|
@@instance = nil
|
46
|
-
puts "Disconnected from #{
|
45
|
+
puts "Disconnected from #{instance.amqp_url}"
|
47
46
|
end
|
48
47
|
|
49
48
|
private
|
@@ -4,6 +4,7 @@ module AngieCoreApi
|
|
4
4
|
module Messaging
|
5
5
|
class Exchange
|
6
6
|
def self.exchange(exchange_name, type:, routing_key:, queue: nil, exchange_options: {}, queue_options: {})
|
7
|
+
return unless AMQPClient.instance.connection&.connected?
|
7
8
|
channel = AMQPClient.instance.channel
|
8
9
|
@exchange_name = exchange_name
|
9
10
|
|
@@ -17,6 +18,7 @@ module AngieCoreApi
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def self.subscribe(options = { manual_ack: false })
|
21
|
+
return unless AMQPClient.instance.connection&.connected?
|
20
22
|
# TODO: show usage?
|
21
23
|
raise "Exchange is not defined" unless @exchange
|
22
24
|
raise "Queue is not defined" unless @queue
|
@@ -29,6 +31,7 @@ module AngieCoreApi
|
|
29
31
|
end
|
30
32
|
|
31
33
|
def self.publish(payload, options = {})
|
34
|
+
return unless AMQPClient.instance.connection&.connected?
|
32
35
|
# TODO: show usage?
|
33
36
|
raise "Exchange is not defined" unless @exchange
|
34
37
|
raise "Routing key is not defined" unless options.has_key?(:routing_key)
|