Skip to content

improve: use ctx and timer instead sleep - #1256

Merged
nodece merged 2 commits into
apache:masterfrom
nodece:user-ctx-timer-instead-sleep
Nov 15, 2024
Merged

nodece merged 2 commits into
apache:masterfrom
nodece:user-ctx-timer-instead-sleep

Conversation

@nodece

@nodece nodece commented Jul 25, 2024

Copy link
Copy Markdown
Member

Motivation

We are using time.Sleep and for to execute the retry, which cannot be interrupted, this PR will use context and timer to improve this behavior.

The next improvement idea supports passing the context to interrupt the retry, when closing the producer or consumer, we need to do that.

Modifications

  • Add the Retry method to execute the try, and use Retry instead of time.Sleep and for.

@nodece
nodece requested review from RobertIndie and merlimat July 26, 2024 03:29

@RobertIndie RobertIndie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall looks good to me. Left one comment.

Comment thread pulsar/consumer_partition.go Resolved
Comment thread pulsar/internal/retry.go Resolved
@nodece
nodece requested a review from RobertIndie July 31, 2024 04:08
@nodece
nodece force-pushed the user-ctx-timer-instead-sleep branch 2 times, most recently from 8d8b6f2 to d32ac75 Compare July 31, 2024 06:44
Comment thread pulsar/consumer_test.go Resolved
Comment thread pulsar/internal/retry.go Resolved
@nodece

nodece commented Jul 31, 2024 •

Copy link
Copy Markdown
Member Author

Let me fix the consumer seek test first.

@nodece

nodece commented Aug 14, 2024

Copy link
Copy Markdown
Member Author

Seek test will be fixed by #1265.

@RobertIndie RobertIndie modified the milestones: v0.14.0, v0.15.0 Oct 8, 2024
@nodece
nodece force-pushed the user-ctx-timer-instead-sleep branch from e307794 to f7caa08 Compare November 7, 2024 09:26
@nodece
nodece force-pushed the user-ctx-timer-instead-sleep branch from f7caa08 to 9904d77 Compare November 7, 2024 09:33
@nodece

nodece commented Nov 8, 2024

Copy link
Copy Markdown
Member Author

@RobertIndie @crossoverJie Could you have a chance to review?

Comment thread pulsar/consumer_partition.go Resolved
@nodece
nodece requested a review from crossoverJie November 15, 2024 03:30

@crossoverJie crossoverJie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@nodece
nodece merged commit 92c6e28 into apache:master Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants