phobos 2.1.0 → 2.1.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/CHANGELOG.md +4 -0
- data/lib/phobos/version.rb +1 -1
- data/lib/phobos.rb +2 -92
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6ec70d6f78852088846db2f5cee6673e9889962379bd82934758aa936886f1df
|
|
4
|
+
data.tar.gz: f0d5a40fb1acbf02e0ac6cae4121571eb72689bc13076505153f33cef48f2362
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c7192c98b0e3f3b22ab3aa4ef4f28bf3227410120012d3b77a66f018960f0e72309f72d47a00e505355d906826dc89bdc327ceea50a99ea7e28d233602bd8ec6
|
|
7
|
+
data.tar.gz: b1dab967fb374559b98d976b0628140692f9c080d3de55d17edaa2a885a4ef17a1bbf7555a380ef00199e62a002f0bdd6d56486e77fbe4f2176eb39756c4f185
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
6
6
|
``
|
|
7
7
|
## UNRELEASED
|
|
8
8
|
|
|
9
|
+
## [2.1.1] - 2022-01-26
|
|
10
|
+
|
|
11
|
+
- Fix crash on Ruby 3.1 involving a change to the Psych gem.
|
|
12
|
+
|
|
9
13
|
## [2.1.0] - 2021-05-27
|
|
10
14
|
|
|
11
15
|
- Modify config to allow specifying kafka connection information separately for consumers and producers
|
data/lib/phobos/version.rb
CHANGED
data/lib/phobos.rb
CHANGED
|
@@ -13,7 +13,7 @@ require 'kafka'
|
|
|
13
13
|
require 'logging'
|
|
14
14
|
require 'erb'
|
|
15
15
|
|
|
16
|
-
require 'phobos/
|
|
16
|
+
require 'phobos/configuration'
|
|
17
17
|
require 'phobos/version'
|
|
18
18
|
require 'phobos/constants'
|
|
19
19
|
require 'phobos/log'
|
|
@@ -49,22 +49,11 @@ module Logging
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
module Phobos
|
|
52
|
+
extend Configuration
|
|
52
53
|
class << self
|
|
53
54
|
attr_reader :config, :logger
|
|
54
55
|
attr_accessor :silence_log
|
|
55
56
|
|
|
56
|
-
def configure(configuration)
|
|
57
|
-
@config = fetch_configuration(configuration)
|
|
58
|
-
@config.class.send(:define_method, :producer_hash) do
|
|
59
|
-
Phobos.config.producer&.to_hash&.except(:kafka)
|
|
60
|
-
end
|
|
61
|
-
@config.class.send(:define_method, :consumer_hash) do
|
|
62
|
-
Phobos.config.consumer&.to_hash&.except(:kafka)
|
|
63
|
-
end
|
|
64
|
-
@config.listeners ||= []
|
|
65
|
-
configure_logger
|
|
66
|
-
end
|
|
67
|
-
|
|
68
57
|
def add_listeners(configuration)
|
|
69
58
|
listeners_config = fetch_configuration(configuration)
|
|
70
59
|
@config.listeners += listeners_config.listeners
|
|
@@ -92,84 +81,5 @@ module Phobos
|
|
|
92
81
|
warn "DEPRECATION WARNING: #{message}: #{location}"
|
|
93
82
|
end
|
|
94
83
|
|
|
95
|
-
# :nodoc:
|
|
96
|
-
def configure_logger
|
|
97
|
-
Logging.backtrace(true)
|
|
98
|
-
Logging.logger.root.level = silence_log ? :fatal : config.logger.level
|
|
99
|
-
|
|
100
|
-
configure_ruby_kafka_logger
|
|
101
|
-
configure_phobos_logger
|
|
102
|
-
|
|
103
|
-
logger.info do
|
|
104
|
-
Hash(message: 'Phobos configured', env: ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'N/A')
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
private
|
|
109
|
-
|
|
110
|
-
def fetch_configuration(configuration)
|
|
111
|
-
DeepStruct.new(read_configuration(configuration))
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
def read_configuration(configuration)
|
|
115
|
-
return configuration.to_h if configuration.respond_to?(:to_h)
|
|
116
|
-
|
|
117
|
-
YAML.safe_load(
|
|
118
|
-
ERB.new(
|
|
119
|
-
File.read(File.expand_path(configuration))
|
|
120
|
-
).result,
|
|
121
|
-
[Symbol],
|
|
122
|
-
[],
|
|
123
|
-
true
|
|
124
|
-
)
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
def configure_phobos_logger
|
|
128
|
-
if config.custom_logger
|
|
129
|
-
@logger = config.custom_logger
|
|
130
|
-
else
|
|
131
|
-
@logger = Logging.logger[self]
|
|
132
|
-
@logger.appenders = logger_appenders
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def configure_ruby_kafka_logger
|
|
137
|
-
if config.custom_kafka_logger
|
|
138
|
-
@ruby_kafka_logger = config.custom_kafka_logger
|
|
139
|
-
elsif config.logger.ruby_kafka
|
|
140
|
-
@ruby_kafka_logger = Logging.logger['RubyKafka']
|
|
141
|
-
@ruby_kafka_logger.appenders = logger_appenders
|
|
142
|
-
@ruby_kafka_logger.level = silence_log ? :fatal : config.logger.ruby_kafka.level
|
|
143
|
-
else
|
|
144
|
-
@ruby_kafka_logger = nil
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
def logger_appenders
|
|
149
|
-
appenders = [Logging.appenders.stdout(layout: stdout_layout)]
|
|
150
|
-
|
|
151
|
-
if log_file
|
|
152
|
-
FileUtils.mkdir_p(File.dirname(log_file))
|
|
153
|
-
appenders << Logging.appenders.file(log_file, layout: json_layout)
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
appenders
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
def log_file
|
|
160
|
-
config.logger.file
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
def json_layout
|
|
164
|
-
Logging.layouts.json(date_pattern: Constants::LOG_DATE_PATTERN)
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
def stdout_layout
|
|
168
|
-
if config.logger.stdout_json == true
|
|
169
|
-
json_layout
|
|
170
|
-
else
|
|
171
|
-
Logging.layouts.pattern(date_pattern: Constants::LOG_DATE_PATTERN)
|
|
172
|
-
end
|
|
173
|
-
end
|
|
174
84
|
end
|
|
175
85
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: phobos
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1.
|
|
4
|
+
version: 2.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Túlio Ornelas
|
|
@@ -15,7 +15,7 @@ authors:
|
|
|
15
15
|
autorequire:
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
|
-
date:
|
|
18
|
+
date: 2022-01-26 00:00:00.000000000 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: bundler
|
|
@@ -314,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
314
314
|
- !ruby/object:Gem::Version
|
|
315
315
|
version: '0'
|
|
316
316
|
requirements: []
|
|
317
|
-
rubygems_version: 3.
|
|
317
|
+
rubygems_version: 3.3.3
|
|
318
318
|
signing_key:
|
|
319
319
|
specification_version: 4
|
|
320
320
|
summary: Simplifying Kafka for ruby apps
|