sbmt-kafka_producer 3.0.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/Gemfile +1 -1
- data/README.md +4 -4
- data/lib/sbmt/kafka_producer/base_producer.rb +44 -6
- data/lib/sbmt/kafka_producer/logger.rb +4 -0
- data/lib/sbmt/kafka_producer/testing/configure_producer_client.rb +3 -1
- data/lib/sbmt/kafka_producer/version.rb +1 -1
- 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: df2d6a732b779366dbb7f47c0f3b97020cdf21772f72c94ea20bc929ddc8cdad
|
4
|
+
data.tar.gz: 3327e30a17a00cc1a200e87cf40db7e22d03a4494c54fae4d4dcc237e88e1ff2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc264c48c8979e1a8ae288132a83e384957e2a8341b6f699d5a0801124d3a17c062fb45e80b6bdec389b0a29fab1afeed689b8598802ec233d68050254c59dc1
|
7
|
+
data.tar.gz: 51b34e850f32e9f7442455f2dab19dbc924ee3dd91c22cfb9824556c2c8674472f3e5d0ba490718a054207613980b3a52b4cd13221a6a4f04e8c8336d1fbd660
|
data/CHANGELOG.md
CHANGED
@@ -13,6 +13,22 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
13
13
|
|
14
14
|
### Fixed
|
15
15
|
|
16
|
+
## [3.1.1] - 2024-10-31
|
17
|
+
|
18
|
+
### Changed
|
19
|
+
|
20
|
+
- Update README
|
21
|
+
|
22
|
+
## [3.1.0] - 2024-09-13
|
23
|
+
|
24
|
+
### Added
|
25
|
+
|
26
|
+
- For synchronous messages and errors, we place logs in tags
|
27
|
+
|
28
|
+
### Fixed
|
29
|
+
|
30
|
+
- Fixed mock for tests
|
31
|
+
|
16
32
|
## [3.0.0] - 2024-08-27
|
17
33
|
|
18
34
|
## BREAKING
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -66,7 +66,7 @@ default: &default
|
|
66
66
|
# see more options at https://github.com/karafka/waterdrop/blob/master/lib/waterdrop/config.rb
|
67
67
|
wait_on_queue_full: true
|
68
68
|
max_payload_size: 1000012
|
69
|
-
|
69
|
+
max_wait_timeout: 60000
|
70
70
|
auth:
|
71
71
|
kind: plaintext
|
72
72
|
kafka:
|
@@ -77,9 +77,9 @@ default: &default
|
|
77
77
|
retry_backoff: 1000 # in milliseconds, optional, default: 1000
|
78
78
|
connect_timeout: 2000 # in milliseconds, optional, default: 2000
|
79
79
|
message_timeout: 55000 # in milliseconds, optional, default: 55000
|
80
|
-
kafka_config: # low-level custom Kafka options
|
81
|
-
|
82
|
-
|
80
|
+
# kafka_config: # optional, low-level custom Kafka options (see https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md)
|
81
|
+
# queue.buffering.max.messages: 100000
|
82
|
+
# queue.buffering.max.ms: 5
|
83
83
|
|
84
84
|
development:
|
85
85
|
<<: *default
|
@@ -5,14 +5,18 @@ module Sbmt
|
|
5
5
|
class BaseProducer
|
6
6
|
extend Dry::Initializer
|
7
7
|
|
8
|
+
MSG_SUCCESS = "Message has been successfully sent to Kafka"
|
9
|
+
|
8
10
|
option :client, default: -> { KafkaClientFactory.default_client }
|
9
11
|
option :topic
|
10
12
|
|
11
13
|
def sync_publish!(payload, options = {})
|
12
|
-
report = around_publish do
|
13
|
-
|
14
|
+
report, produce_duration = around_publish do
|
15
|
+
measure_time do
|
16
|
+
client.produce_sync(payload: payload, **options.merge(topic: topic))
|
17
|
+
end
|
14
18
|
end
|
15
|
-
log_success(report)
|
19
|
+
log_success(report, produce_duration)
|
16
20
|
true
|
17
21
|
end
|
18
22
|
|
@@ -78,12 +82,19 @@ module Sbmt
|
|
78
82
|
def log_error(error)
|
79
83
|
return true if ignore_kafka_errors?
|
80
84
|
|
81
|
-
|
85
|
+
log_tags = {stacktrace: error.backtrace.join("\n")}
|
86
|
+
|
87
|
+
logger.tagged(log_tags) do
|
88
|
+
logger.send(:error, "KAFKA ERROR: #{format_exception_error(error)}")
|
89
|
+
end
|
90
|
+
|
82
91
|
ErrorTracker.error(error)
|
83
92
|
end
|
84
93
|
|
85
|
-
def log_success(report)
|
86
|
-
|
94
|
+
def log_success(report, produce_duration)
|
95
|
+
log_tags = {kafka: log_tags(report, produce_duration)}
|
96
|
+
|
97
|
+
log_with_tags(log_tags)
|
87
98
|
end
|
88
99
|
|
89
100
|
def format_exception_error(error)
|
@@ -100,6 +111,33 @@ module Sbmt
|
|
100
111
|
error.respond_to?(:cause) && error.cause.present?
|
101
112
|
end
|
102
113
|
|
114
|
+
def log_tags(report, produce_duration)
|
115
|
+
{
|
116
|
+
topic: report.topic_name,
|
117
|
+
partition: report.partition,
|
118
|
+
offset: report.offset,
|
119
|
+
produce_duration_ms: produce_duration
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
123
|
+
def log_with_tags(log_tags)
|
124
|
+
return unless logger.respond_to?(:tagged)
|
125
|
+
|
126
|
+
logger.tagged(log_tags) do
|
127
|
+
logger.send(:info, MSG_SUCCESS)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def measure_time
|
132
|
+
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
133
|
+
result = yield
|
134
|
+
end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
135
|
+
|
136
|
+
elapsed_time = end_time - start_time
|
137
|
+
|
138
|
+
[result, elapsed_time]
|
139
|
+
end
|
140
|
+
|
103
141
|
def config
|
104
142
|
Config::Producer
|
105
143
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sbmt-kafka_producer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kuper Ruby-Platform Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: anyway_config
|
@@ -426,7 +426,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
426
426
|
- !ruby/object:Gem::Version
|
427
427
|
version: '0'
|
428
428
|
requirements: []
|
429
|
-
rubygems_version: 3.
|
429
|
+
rubygems_version: 3.1.6
|
430
430
|
signing_key:
|
431
431
|
specification_version: 4
|
432
432
|
summary: Ruby gem for producing Kafka messages
|