chili_logger 0.0.9.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.byebug_history +47 -105
- data/.gitignore +2 -0
- data/Gemfile +3 -2
- data/Gemfile.lock +20 -13
- data/README.md +131 -93
- data/chili_logger.gemspec +2 -1
- data/lib/brokers/main_broker.rb +47 -0
- data/lib/brokers/rabbit_broker.rb +17 -31
- data/lib/brokers/sqs_broker.rb +43 -19
- data/lib/chili_logger.rb +16 -29
- data/lib/chili_logger/version.rb +1 -1
- data/lib/current_log_accessor.rb +1 -5
- data/lib/errors/logging_error_handler/logging_error_handler.rb +23 -8
- data/lib/helpers/logs_coverage/coverage_writer.rb +4 -2
- data/lib/helpers/values/default.rb +2 -2
- data/lib/helpers/values/secrets/aws_secrets_manager.rb +39 -0
- data/lib/helpers/values/secrets/secrets.rb +29 -0
- data/lib/unpublished_logs_manager/unpublished_logs_manager.rb +47 -0
- data/log/chili-logger-coverage.yml +8 -2
- metadata +22 -14
- data/chili_logger-0.0.6.gem +0 -0
- data/chili_logger-0.0.7.gem +0 -0
- data/chili_logger-0.0.8.gem +0 -0
- data/chili_logger-0.0.9.gem +0 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'aws-sdk-secretsmanager'
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
# class for centralizing Creative's logging logic
|
5
|
+
class ChiliLogger
|
6
|
+
# module responsible for uniformization of values in ChiliLogger
|
7
|
+
module Values
|
8
|
+
# class to centralize access to all secrets stored in 3rd-party managers
|
9
|
+
class Secrets
|
10
|
+
# Module to load secrets environment variables
|
11
|
+
class AwsSecretsManager
|
12
|
+
def initialize(region_name = 'us-east-1')
|
13
|
+
@client = Aws::SecretsManager::Client.new(region: region_name)
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_secrets_collection(collection_name)
|
17
|
+
JSON.parse(get_secret(collection_name))
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# Use this code snippet in your app.
|
23
|
+
# If you need more information about configurations or implementing the sample code, visit the AWS docs:
|
24
|
+
# https://aws.amazon.com/developers/getting-started/ruby/
|
25
|
+
# method from AWS example, ipsis literis
|
26
|
+
def get_secret(secret_name)
|
27
|
+
# In this sample we only handle the specific exceptions for the 'GetSecretValue' API.
|
28
|
+
# See https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_GetSecretValue.html
|
29
|
+
# We rethrow the exception by default.
|
30
|
+
get_secret_value_response = @client.get_secret_value(secret_id: secret_name)
|
31
|
+
|
32
|
+
# Decrypts secret using the associated KMS CMK.
|
33
|
+
# Depending on whether the secret is a string or binary, one of these fields will be populated.
|
34
|
+
get_secret_value_response.secret_string || Base64.decode64(get_secret_value_response.secret_binary)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'helpers/values/secrets/aws_secrets_manager'
|
2
|
+
|
3
|
+
# class for centralizing Creative's logging logic
|
4
|
+
class ChiliLogger
|
5
|
+
# module responsible for uniformization of values in ChiliLogger
|
6
|
+
module Values
|
7
|
+
# class to centralize access to all secrets stored in 3rd-party managers
|
8
|
+
class Secrets
|
9
|
+
def initialize(manager_name = 'aws')
|
10
|
+
manager_class = supported_managers[manager_name.to_s]
|
11
|
+
manager_class ||= supported_managers['aws']
|
12
|
+
|
13
|
+
@secrets_manager = manager_class.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_secrets_collection(collection_name)
|
17
|
+
@secrets_manager.get_secrets_collection(collection_name)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def supported_managers
|
23
|
+
{
|
24
|
+
'aws' => AwsSecretsManager
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'errors/error_messages/config_error'
|
2
|
+
require 'brokers/main_broker'
|
3
|
+
require 'errors/logging_error_handler/logging_error_handler'
|
4
|
+
|
5
|
+
# class for centralizing Creative's logging logic
|
6
|
+
class ChiliLogger
|
7
|
+
# class for manipulating unpublished logs that were sent to the fallback_broker
|
8
|
+
class UnpublishedLogsManager
|
9
|
+
def initialize(msg_broker, logging_error_handler)
|
10
|
+
validate_msg_broker_type(msg_broker)
|
11
|
+
validate_logging_error_handler_type(logging_error_handler)
|
12
|
+
|
13
|
+
@msg_broker = msg_broker
|
14
|
+
@logging_error_handler = logging_error_handler
|
15
|
+
end
|
16
|
+
|
17
|
+
def republish
|
18
|
+
unpub_logs = @logging_error_handler.fetch_unpublished_logs
|
19
|
+
|
20
|
+
unpub_logs.each do |unpub_log|
|
21
|
+
fallback_broker_msg = unpub_log[:fallback_broker_msg]
|
22
|
+
log = unpub_log[:log]
|
23
|
+
|
24
|
+
# if a message can't be published by MainBroker, LoggingErrorHandler sends it to the fallback_broker
|
25
|
+
# to avoid duplicates in this scenario, we delete the message before even trying to publish it
|
26
|
+
@logging_error_handler.delete_unpublished_log(fallback_broker_msg)
|
27
|
+
@msg_broker.publish(log)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def validate_msg_broker_type(msg_broker)
|
34
|
+
err_type = ChiliLogger::ConfigError
|
35
|
+
err_msg = "#{msg_broker.inspect} should be an instance of ChiliLogger::MainBroker"
|
36
|
+
|
37
|
+
raise(err_type, err_msg) unless msg_broker.class == ChiliLogger::MainBroker
|
38
|
+
end
|
39
|
+
|
40
|
+
def validate_logging_error_handler_type(error_handler)
|
41
|
+
err_type = ChiliLogger::ConfigError
|
42
|
+
err_msg = "#{error_handler} should be an instance of ChiliLogger::LoggingError::Handler"
|
43
|
+
|
44
|
+
raise(err_type, err_msg) unless error_handler.class == ChiliLogger::LoggingErrorHandler
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -51,9 +51,15 @@ test:
|
|
51
51
|
transaction:
|
52
52
|
console:
|
53
53
|
publish_test:
|
54
|
-
- "/home/lucas/.rvm/gems/ruby-2.3.3/gems/chili_logger-0.0
|
54
|
+
- "/home/lucas/.rvm/gems/ruby-2.3.3/gems/chili_logger-0.1.0/lib/chili_logger.rb:61:in
|
55
|
+
`publish_instant_log'"
|
56
|
+
- "(pry):189:in `block (2 levels) in __pry__'"
|
57
|
+
uncaught_error:
|
58
|
+
console:
|
59
|
+
publish_test:
|
60
|
+
- "/home/lucas/.rvm/gems/ruby-2.3.3/gems/chili_logger-0.1.0/lib/chili_logger.rb:61:in
|
55
61
|
`publish_instant_log'"
|
56
|
-
- "(pry):
|
62
|
+
- "(pry):10:in `__pry__'"
|
57
63
|
- "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/pry_instance.rb:290:in
|
58
64
|
`eval'"
|
59
65
|
- "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/pry_instance.rb:290:in
|
metadata
CHANGED
@@ -1,35 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chili_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lucas sandeville
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: aws-sdk
|
14
|
+
name: aws-sdk-sqs
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 2.9.0
|
20
17
|
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
19
|
+
version: 1.30.0
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
26
|
+
version: 1.30.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aws-sdk-secretsmanager
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.36.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
30
38
|
- - "~>"
|
31
39
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
40
|
+
version: 1.36.0
|
33
41
|
- !ruby/object:Gem::Dependency
|
34
42
|
name: bunny
|
35
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,11 +89,8 @@ files:
|
|
81
89
|
- assets/images/rabbit-topic-explanation.webp
|
82
90
|
- bin/console
|
83
91
|
- bin/setup
|
84
|
-
- chili_logger-0.0.6.gem
|
85
|
-
- chili_logger-0.0.7.gem
|
86
|
-
- chili_logger-0.0.8.gem
|
87
|
-
- chili_logger-0.0.9.gem
|
88
92
|
- chili_logger.gemspec
|
93
|
+
- lib/brokers/main_broker.rb
|
89
94
|
- lib/brokers/rabbit_broker.rb
|
90
95
|
- lib/brokers/sqs_broker.rb
|
91
96
|
- lib/chili_logger.rb
|
@@ -97,11 +102,14 @@ files:
|
|
97
102
|
- lib/helpers/logs_coverage/coverage_writer.rb
|
98
103
|
- lib/helpers/logs_coverage/levantamento_provisório.yaml
|
99
104
|
- lib/helpers/values/default.rb
|
105
|
+
- lib/helpers/values/secrets/aws_secrets_manager.rb
|
106
|
+
- lib/helpers/values/secrets/secrets.rb
|
100
107
|
- lib/helpers/values/type_uniformizer/desc.rb
|
101
108
|
- lib/helpers/values/type_uniformizer/main_content.rb
|
102
109
|
- lib/helpers/values/type_uniformizer/user.rb
|
103
110
|
- lib/message_writer/aws_ops_metadata.rb
|
104
111
|
- lib/message_writer/message_writer.rb
|
112
|
+
- lib/unpublished_logs_manager/unpublished_logs_manager.rb
|
105
113
|
- log/chili-logger-coverage.yml
|
106
114
|
homepage: https://gitlab.com/chiligumdev/chili_logger
|
107
115
|
licenses:
|
data/chili_logger-0.0.6.gem
DELETED
Binary file
|
data/chili_logger-0.0.7.gem
DELETED
Binary file
|
data/chili_logger-0.0.8.gem
DELETED
Binary file
|
data/chili_logger-0.0.9.gem
DELETED
Binary file
|