Skip to content

Merge our changes into updated master branch#2

Open
yboulkaid wants to merge 17 commits intomasterfrom
v0.7.5-workato
Open

Merge our changes into updated master branch#2
yboulkaid wants to merge 17 commits intomasterfrom
v0.7.5-workato

Conversation

@yboulkaid
Copy link

@yboulkaid yboulkaid commented May 12, 2023

Our fork of ruby-kafka has fallen behind the gem's master, which made us miss the improvements and bugfixes as well as made it hard to add code changes to our fork because the specs were failing (because of for example this)

This PR ports the changes we made to our fork to the latest master. Note that the diff of the custom code removal can be seen in this commit

The main changes we had made in this fork are:

  1. Add a retry limit and backoff to errors due to BufferOverflow. Similar changes were also implemented upsteam, so we don't need to have our custom version anymore. See the merge commit for the removal diff.
  2. Adding ruby-kafka: as a prefix to our log outputs so it's easier to filter the log lines coming from ruby-kafka.
    This has been replaced by adding ruby-kafka as a default log tag in the Kafka::TaggedLogger class, so that all logging coming from this gem automatically has [ruby-kafka] appended. See the merge commit for the removal diff.
  3. Add more logging statements. These changes are kept as-is
  4. Force the SSL version and SSL verify mode. These changes are kept as-is.

@yboulkaid yboulkaid requested review from faberge-eggs and notmaxx May 12, 2023 10:39
@yboulkaid yboulkaid changed the title Merge workato fixes to master Merge ruby-kafka workato fixes to master May 12, 2023
raise ArgumentError unless delivery_threshold >= 0
raise ArgumentError unless delivery_interval >= 0
raise ArgumentError unless max_retries >= 0
raise ArgumentError unless retry_backoff >= 0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These checks were in our fork but not in the official version. We backport them to keep existing behavior.

@yboulkaid yboulkaid requested a review from climber73 May 12, 2023 10:45
@yboulkaid
Copy link
Author

This is tested and verified working on preview 👌

# We use our object ID here to avoid conflicting with other instances
thread_key = @thread_key ||= "kafka_tagged_logging_tags:#{object_id}".freeze
Thread.current[thread_key] ||= []
Thread.current[thread_key] ||= ["ruby-kafka"]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tagged logging in action:
Screenshot 2023-05-12 at 15 05 00

@yboulkaid yboulkaid requested a review from vladkorobkov May 22, 2023 11:21
@yboulkaid
Copy link
Author

I dug up the exact diffs introducing the retry logic in our fork and in the upstream fork to make sure the logic is the same:

Screenshot 2023-05-23 at 11 14 20

Our fork, Upstream

The only difference is that our fork sleeps a constant duration (retry_backoff), and the upstream code uses exponential backoff (retry_backoff**retries), so we have to adapt the values when updating the gem in our app.

@yboulkaid yboulkaid changed the title Merge ruby-kafka workato fixes to master Merge upstream master changes int our custom fork May 23, 2023
@yboulkaid yboulkaid changed the title Merge upstream master changes int our custom fork Merge upstream changes int our custom fork May 23, 2023
@yboulkaid yboulkaid changed the title Merge upstream changes int our custom fork Merge upstream changes into our custom fork May 23, 2023
@notmaxx
Copy link

notmaxx commented May 25, 2023

regarding #2 (comment)

@yboulkaid thank you for comparison. Could we keep our logic instead of upstream's? I believe it has better configurability. Moreover if upstream is not supported anymore it doesn't make sense to send PR to upstream

))

if message.bytesize >= @max_buffer_bytesize
buffer_overflow topic, "Message is too big: message_bytesize=#{message.bytesize}"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yboulkaid where is buffer_overflow function defined?

Copy link
Author

@yboulkaid yboulkaid May 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's defined in the AsyncProducer:

def buffer_overflow(topic, message)

This is the helper method that's used by the rest of the class to raise BufferOverflow errors

@yboulkaid
Copy link
Author

yboulkaid commented May 26, 2023

Could we keep our logic instead of upstream's? I believe it has better configurability. Moreover if upstream is not supported anymore it doesn't make sense to send PR to upstream

Sure! I'll make the change

@yboulkaid
Copy link
Author

yboulkaid commented May 31, 2023

Could we keep our logic instead of upstream's?

I used our logic instead of upstream in 23a8f75

@yboulkaid yboulkaid changed the title Merge upstream changes into our custom fork Merge our changes into updated master branch May 31, 2023
@yboulkaid yboulkaid requested a review from notmaxx May 31, 2023 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants