Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
The ruby_kafka_retry
gem provides a mechanism to handle message retries and dead-letter queue (DLQ) functionality in Ruby applications using Kafka. It ensures messages are retried with an increasing delay before being sent to a DLQ.
Add this token to bundle config for the gem installation access
bundle config rubygems.pkg.github.com veeraveeraveera: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
Add this line to your application's Gemfile:
source "https://rubygems.pkg.github.com/veeraveeraveera" do
gem "ruby_kafka_retry", "0.1.0"
end
And then execute:
$ bundle install
To handle message retries, use the RubyKafkaRetry::RetryFailedEvent
class. This class allows you to specify the retry topic, DLQ topic, and the message to be retried, along with an optional maximum retry attempt count.
retry_topic = 'my_retry_topic'
dlq_topic = 'my_dlq_topic'
topic_message = { key: 'value' } # The message to be processed
max_retry_attempt = 5 # Optional parameter, default is 3 if not provided
retry_event = RubyKafkaRetry::RetryFailedEvent.new(retry_topic, dlq_topic, topic_message, max_retry_attempt)
retry_event.retry
current_retry_attempt
key, the gem considers it as the first retry attempt and current_retry_attempt
will be appended to the topic_message
with the value as 1. The modified topic_message
will then be published to the retry_topic.topic_message
must be a hash. If a non-hash object is passed, the gem will raise an error:
raise TypeError, 'topic_message must be a Hash'
current_retry_attempt
value in the topic_message reaches the max_retry_attempt
count, the message will be published to the DLQ topic.current_retry_attempt
value is less than the max_retry_attempt
, the current_retry_attempt
value will be incremented, and the message will be republished to the retry_topic
after a delay.2 ** current_retry_attempt
minutes.max_retry_attempt
parameter is optional. If it is not provided, the default value is 3
.Here's a step-by-step example workflow:
topic_message = { key: 'value' }
is received and processed.current_retry_attempt
key is added to the message if not present.{ key: 'value', current_retry_attempt: 1 }
.retry_topic
after a delay of 2 ** 1 (2 minutes).current_retry_attempt
reaches max_retry_attempt
.max_retry_attempt
is reached, the message is published to the DLQ topic.You need to configure the gem by creating a YAML configuration file at config/ruby_kafka_retry.yml
. This file should contain the following settings:
development:
client_id: "my_kafka_client_id"
brokers:
- "localhost:9092"
ssl_ca_certs_from_system: false
redis_host: "127.0.0.1"
redis_db: "10"
redis_port: "6379"
sidekiq_queue: "test_retry_queue"
stage:
client_id: "my_kafka_client_id"
brokers:
- "localhost:9092"
ssl_ca_certs_from_system: false
redis_host: "127.0.0.1"
redis_db: "10"
redis_port: "6379"
sidekiq_queue: "test_retry_queue"
production:
client_id: "my_kafka_client_id"
brokers:
- "localhost:9092"
ssl_ca_certs_from_system: false
redis_host: "127.0.0.1"
redis_db: "10"
redis_port: "6379"
sidekiq_queue: "test_retry_queue"
add the same sidekiq_queue
in sidekiq.yml
file as well
The ruby_kafka_retry
gem depends on the following gems:
To use this gem, ensure the following services are running in the background:
After checking out the repo, run bin/setup
to install dependencies. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/veeraveeraveera/ruby_kafka_retry.
FAQs
Unknown package
We found that ruby_kafka_retry demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.