Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE 615: Changes to support "seekEpoch", "seekTimestamp" in Kafka Consumer step, removing "seek" from ConsumerCommonConfigs #619

Merged
merged 10 commits into from
Feb 14, 2024

Conversation

a1shadows
Copy link
Collaborator

@a1shadows a1shadows commented Jan 28, 2024

New Feature: Support to consume on all partitions from specified timestamp/epoch

PR Branch
https://github.com/a1shadows/zerocode/tree/issue-615/seekToTimestamp

fixes #615
fixes #621

Motivation and Context

Right now, the seek method available can only seek from one partition and has no semantics to consume from a specific timestamp. It only consumes the last 'n' messages on the specified partition.

With this new feature, we will be able to consume on all partitions from specified timestamp/epoch in the following fashion:

"consumerLocalConfigs" : {
    "seekTimestamp" : {
      "timestamp" : "2024-02-04T14:53:20.071",
      "format" : "yyyy-MM-dd'T'HH:mm:ss.SSS"
    }

or like this:

"consumerLocalConfigs" : {
    "seekEpoch" : "1707038600071"
  }

in the kafka consume step.

In addition, we have also removed "seek" from ConsumerCommonConfigs as it made no sense in a common context and can now only be specified as a consumerLocalConfig.

Checklist:

  • Unit tests added

  • Integration tests added

  • Test names are meaningful

  • Feature manually tested

  • Branch build passed

  • No 'package.*' in the imports

  • Relevant Wiki page updated with clear instruction for the end user

    • Not applicable. This was only a refactor change, no functional or behaviour changes were introduced
  • Http test added to http-testing module(if applicable) ?

    • Not applicable. The changes did not affect HTTP automation flow
  • Kafka test added to kafka-testing module(if applicable) ?

    • Not applicable. The changes did not affect Kafka automation flow

1. Changed epoch seekTimestamp to seekEpoch and added seekTimestamp with format and timestamp
2. Added validations for seekEpoch and seekTimestamp
3. Implemented seekTimestamp feature
@a1shadows a1shadows marked this pull request as ready for review February 4, 2024 09:30
@a1shadows
Copy link
Collaborator Author

@nirmalchandra Which Wiki page should I update with details of use of this feature? Have added a ser/des unit test and an integration test for the feature which is working as expected

@a1shadows a1shadows changed the title ISSUE 615: Changes to support seekFromTimestamp in KafkaReceiver ISSUE 615: Changes to support "seekEpoch", "seekTimestamp" in Kafka Consumer step, removing "seek" from ConsumerCommonConfigs Feb 4, 2024
@a1shadows
Copy link
Collaborator Author

@nirmalchandra @authorjapps @M3lkior hey, let me know if there is any action i need to take on this

pom.xml Outdated
@@ -138,6 +139,13 @@
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Copy link
Owner

@authorjapps authorjapps Feb 7, 2024

Choose a reason for hiding this comment

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

Hi @a1shadows , Great work!

It's preferred to go with simple getter/setter methods, without using lombok.
This has caused IDE dependency, readability and other issues in the past.
Can you please remove this ?

Rest everything looks amazing. 🚀
I might add couple of more scenarios to the test pack before merging.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@authorjapps

I added Lombok to reduce the boilerplate code. Are you sure we want to write explicit getters, setters and constructors for everything?

At my workplace, we have been using Lombok extensively and at great scale with no issues faced so far, and the code stays compact.

Let me know either way and I'll make the changes

Copy link
Owner

Choose a reason for hiding this comment

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

@authorjapps

I added Lombok to reduce the boilerplate code. Are you sure we want to write explicit getters, setters and constructors for everything?

At my workplace, we have been using Lombok extensively and at great scale with no issues faced so far, and the code stays compact.

Let me know either way and I'll make the changes

Thanks for understanding @a1shadows . Kindly make the changes to remove lombok.

Reason is simple, it has happened in the past, worth thinking about the practicality of the issue in terms of benefits.
Thousands of projects are using this library and we wouldn't want to have additional maintenance overhead due to some projects at some corner of the world may comeback with issues, wanting us to fix it.
That will need additional work to reproduce the issue, fix, PR and merge, then release cycle.

Also, can you take a look and fix this CI failure? 🔴
https://github.com/authorjapps/zerocode/pull/619/checks#step:6:12150 (click)

testSerDeser_seekEpoch(org.jsmart.zerocode.core.kafka.consume.ConsumerLocalConfigsWrapTest)  Time elapsed: 0.004 sec  <<< FAILURE!
java.lang.AssertionError: consumerLocalConfigs.seekEpoch
Expected: 1706940293669
     got: 1707299617296

	at org.skyscreamer.jsonassert.JSONAssert.assertEquals(JSONAssert.java:417)
	at org.skyscreamer.jsonassert.JSONAssert.assertEquals(JSONAssert.java:394)
	at org.jsmart.zerocode.core.kafka.consume.ConsumerLocalConfigsWrapTest.testSerDeser_seekEpoch(ConsumerLocalConfigsWrapTest.java:36)
	

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@authorjapps could you let me know on the above point? Also, can you let me know when the PR looks ready to merge? Would love to see a merge commit on my name ? 😁

Copy link
Owner

Choose a reason for hiding this comment

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

@authorjapps could you let me know on the above point? Also, can you let me know when the PR looks ready to merge? Would love to see a merge commit on my name ? 😁

Thanks for understanding @a1shadows .
Can you please make the changes to remove lombok dependency soon you get chance?
Once done, please confirm.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@authorjapps Did you have time to consider Lombok use in the project? We can whittle down the volume of code significantly in the long run if we adopt it. Let me know.

Copy link
Owner

@authorjapps authorjapps Feb 11, 2024

Choose a reason for hiding this comment

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

@authorjapps Did you have time to consider Lombok use in the project? We can whittle down the volume of code significantly in the long run if we adopt it. Let me know.

Already provided my view in this thread.

To add more clarity:
@a1shadows , Lets do it this way to derisk this release if you are keen in using lombok.

  1. For this PR, please remove it and lets release it (version = 1.0.36 )
  2. Raise a new PR with it and we can make a new release with lombok (e.g. version = 1.0.37-RC-lombok )
    (Use this new Issue No. 624 for your commits. ) Release with Lombok dependency (with a RC version) #624

This way we don't introduce overhead with our regular releases, then once the version 1.0.37-RC-lombok becomes stable, we can merge the code to main release.

Can you amend this PR for Point No.1 please?
and
a new PR for Point No.2 please? <--- This is optional as it it is only Dev stuff, really doesn't affect any users

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@authorjapps Hey, I have removed the Lombok dependency and fixed the test. Can you take another look at this?

Copy link
Owner

Choose a reason for hiding this comment

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

@authorjapps Hey, I have removed the Lombok dependency and fixed the test. Can you take another look at this?

Thanks, just given a rerun now on the CI job. Once Green, we should be able to merge.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@authorjapps Looks like CI is a success. Can we merge now?

pom.xml Outdated
@@ -138,6 +139,13 @@
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Copy link
Owner

Choose a reason for hiding this comment

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

@authorjapps

I added Lombok to reduce the boilerplate code. Are you sure we want to write explicit getters, setters and constructors for everything?

At my workplace, we have been using Lombok extensively and at great scale with no issues faced so far, and the code stays compact.

Let me know either way and I'll make the changes

Thanks for understanding @a1shadows . Kindly make the changes to remove lombok.

Reason is simple, it has happened in the past, worth thinking about the practicality of the issue in terms of benefits.
Thousands of projects are using this library and we wouldn't want to have additional maintenance overhead due to some projects at some corner of the world may comeback with issues, wanting us to fix it.
That will need additional work to reproduce the issue, fix, PR and merge, then release cycle.

Also, can you take a look and fix this CI failure? 🔴
https://github.com/authorjapps/zerocode/pull/619/checks#step:6:12150 (click)

testSerDeser_seekEpoch(org.jsmart.zerocode.core.kafka.consume.ConsumerLocalConfigsWrapTest)  Time elapsed: 0.004 sec  <<< FAILURE!
java.lang.AssertionError: consumerLocalConfigs.seekEpoch
Expected: 1706940293669
     got: 1707299617296

	at org.skyscreamer.jsonassert.JSONAssert.assertEquals(JSONAssert.java:417)
	at org.skyscreamer.jsonassert.JSONAssert.assertEquals(JSONAssert.java:394)
	at org.jsmart.zerocode.core.kafka.consume.ConsumerLocalConfigsWrapTest.testSerDeser_seekEpoch(ConsumerLocalConfigsWrapTest.java:36)
	

pom.xml Outdated
@@ -138,6 +139,13 @@
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Copy link
Owner

Choose a reason for hiding this comment

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

@authorjapps could you let me know on the above point? Also, can you let me know when the PR looks ready to merge? Would love to see a merge commit on my name ? 😁

Thanks for understanding @a1shadows .
Can you please make the changes to remove lombok dependency soon you get chance?
Once done, please confirm.

pom.xml Outdated
@@ -138,6 +139,13 @@
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Copy link
Owner

@authorjapps authorjapps Feb 11, 2024

Choose a reason for hiding this comment

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

@authorjapps Did you have time to consider Lombok use in the project? We can whittle down the volume of code significantly in the long run if we adopt it. Let me know.

Already provided my view in this thread.

To add more clarity:
@a1shadows , Lets do it this way to derisk this release if you are keen in using lombok.

  1. For this PR, please remove it and lets release it (version = 1.0.36 )
  2. Raise a new PR with it and we can make a new release with lombok (e.g. version = 1.0.37-RC-lombok )
    (Use this new Issue No. 624 for your commits. ) Release with Lombok dependency (with a RC version) #624

This way we don't introduce overhead with our regular releases, then once the version 1.0.37-RC-lombok becomes stable, we can merge the code to main release.

Can you amend this PR for Point No.1 please?
and
a new PR for Point No.2 please? <--- This is optional as it it is only Dev stuff, really doesn't affect any users

Copy link
Collaborator

@nirmalchandra nirmalchandra left a comment

Choose a reason for hiding this comment

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

Good work. Approved

@nirmalchandra nirmalchandra merged commit f72319d into authorjapps:master Feb 14, 2024
1 check passed
@a1shadows a1shadows deleted the issue-615/seekToTimestamp branch February 15, 2024 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants