bug_bunny 0.2.5 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bug_bunny/config.rb +11 -0
- data/lib/bug_bunny/rabbit.rb +13 -15
- data/lib/bug_bunny/version.rb +1 -1
- data/lib/bug_bunny.rb +13 -0
- metadata +5 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04b430be6237b82713e183846665873b602b15ebece1dfc307031f92a665eb0f
|
4
|
+
data.tar.gz: 922b431bf9bf427cd7dab5ece6abc657b08dd759b72c52e7468f4c5d6e58c634
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fef3ed50441448e66f7e23d02189f5b8b51294c14bdfc61f27d3a68fb3b2179b9ada92bdea906ae0d4605a3761a051700a1e3f4957bbb8c4ef6afa0518e2a238
|
7
|
+
data.tar.gz: 3192b179b3e35c4b2850b5933410afdc71a9a904d1df1673a88efb4bb0e66ef2d5952d04def37b7aff82a580b26943d362169ff896924f4ff91a9947223caeb5
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module BugBunny
|
2
|
+
class Config
|
3
|
+
# getter y setter para cada propiedad.
|
4
|
+
attr_accessor :user, :pass, :host, :virtual_host, :logger, :log_level
|
5
|
+
|
6
|
+
# Método para generar la URL de conexión
|
7
|
+
def url
|
8
|
+
"amqp://#{user}:#{pass}@#{host}/#{virtual_host}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/bug_bunny/rabbit.rb
CHANGED
@@ -68,8 +68,6 @@ module BugBunny
|
|
68
68
|
# status = :open, :connected, :connecting,
|
69
69
|
# :closing, :disconnected, :not_connected, :closed
|
70
70
|
def create_connection
|
71
|
-
options = {}
|
72
|
-
|
73
71
|
# if WisproUtils::Config.defaults.use_tls
|
74
72
|
# path = (Rails.root.join('private', 'certs') rescue './private/certs')
|
75
73
|
# options.merge!(tls: true,
|
@@ -80,28 +78,28 @@ module BugBunny
|
|
80
78
|
# tls_key: "#{path}/key.pem",
|
81
79
|
# tls_ca_certificates: ["#{path}/ca.pem"])
|
82
80
|
# end
|
81
|
+
options = {}
|
83
82
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
"/#{ENV['RABBIT_VIRTUAL_HOST']}")
|
83
|
+
raise "Need user" if BugBunny.configuration.user.blank?
|
84
|
+
raise "Need pass" if BugBunny.configuration.pass.blank?
|
85
|
+
raise "Need host" if BugBunny.configuration.host.blank?
|
88
86
|
|
87
|
+
bunny_logger = BugBunny.configuration.logger || ::Logger.new('./log/bunny.log', 7, 10485760)
|
88
|
+
bunny_logger.level = BugBunny.configuration.log_level || ::Logger::INFO
|
89
89
|
|
90
|
-
bunny_logger = ::Logger.new('./log/bunny.log', 7, 10485760)
|
91
|
-
bunny_logger.level = ::Logger::DEBUG
|
92
90
|
options.merge!(
|
93
|
-
heartbeat_interval: 20,
|
91
|
+
heartbeat_interval: 20, # 20.seconds per connection
|
94
92
|
logger: bunny_logger,
|
95
93
|
# Override bunny client_propierties
|
96
|
-
client_properties: { product: identifier, platform: ''}
|
94
|
+
client_properties: { product: identifier, platform: '' }
|
97
95
|
)
|
98
96
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
options)
|
97
|
+
logger&.debug('Stablish new connection to rabbit')
|
98
|
+
logger&.debug(BugBunny.configuration.url)
|
99
|
+
|
100
|
+
rabbit_conn = Bunny.new(BugBunny.configuration.url, options)
|
104
101
|
rabbit_conn.start
|
102
|
+
|
105
103
|
logger&.debug("New status connection: #{rabbit_conn.status}")
|
106
104
|
|
107
105
|
self.connection = rabbit_conn
|
data/lib/bug_bunny/version.rb
CHANGED
data/lib/bug_bunny.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'bunny'
|
4
4
|
require_relative "bug_bunny/version"
|
5
|
+
require_relative "bug_bunny/config"
|
5
6
|
require_relative "bug_bunny/adapter"
|
6
7
|
require_relative "bug_bunny/controller"
|
7
8
|
require_relative "bug_bunny/exception"
|
@@ -18,4 +19,16 @@ if defined? ::Rails::Railtie
|
|
18
19
|
end
|
19
20
|
|
20
21
|
module BugBunny
|
22
|
+
class << self
|
23
|
+
# Aquí guardaremos la instancia de la configuración
|
24
|
+
def configuration
|
25
|
+
@configuration ||= BugBunny::Config.new
|
26
|
+
end
|
27
|
+
|
28
|
+
# Este es el método que usaremos para configurar.
|
29
|
+
# Recibe un bloque de código y le pasa el objeto de configuración.
|
30
|
+
def configure
|
31
|
+
yield(configuration) if block_given?
|
32
|
+
end
|
33
|
+
end
|
21
34
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bug_bunny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gabix
|
@@ -15,28 +15,14 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version:
|
18
|
+
version: 2.24.0
|
19
19
|
type: :runtime
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - "~>"
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version:
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: rubocop
|
28
|
-
requirement: !ruby/object:Gem::Requirement
|
29
|
-
requirements:
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '0'
|
33
|
-
type: :development
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - ">="
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '0'
|
25
|
+
version: 2.24.0
|
40
26
|
description: Gem for sync and async comunication via rabbit bunny.
|
41
27
|
email:
|
42
28
|
- gab.edera@gmail.com
|
@@ -50,6 +36,7 @@ files:
|
|
50
36
|
- Rakefile
|
51
37
|
- lib/bug_bunny.rb
|
52
38
|
- lib/bug_bunny/adapter.rb
|
39
|
+
- lib/bug_bunny/config.rb
|
53
40
|
- lib/bug_bunny/controller.rb
|
54
41
|
- lib/bug_bunny/exception.rb
|
55
42
|
- lib/bug_bunny/helpers.rb
|
@@ -81,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
68
|
- !ruby/object:Gem::Version
|
82
69
|
version: '0'
|
83
70
|
requirements: []
|
84
|
-
rubygems_version: 3.6.
|
71
|
+
rubygems_version: 3.6.7
|
85
72
|
specification_version: 4
|
86
73
|
summary: Gem for sync and async comunication via rabbit bunny.
|
87
74
|
test_files: []
|