-
Notifications
You must be signed in to change notification settings - Fork 37
Added support of RetryConfig to topic writers #637
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9cedc34
Added RetryConfig to WriterSettings
alex268 59c6b94
Update WriterImpl to use TopicRetryableStream
alex268 b7aa9ac
Added test for BufferManager closing
alex268 4809411
Added tests for retries in WriterImpl
alex268 a3ed749
Fixes by copilot
alex268 fe21ca4
Fixed WriterImpl state management
alex268 90f12ed
Added tests for WriterImpl
alex268 a03c4e8
Fixed double init of WriterImpl
alex268 1d65298
Fixes by copilot
alex268 c069b4e
Make WriterImpl closing atomic
alex268 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
topic/src/main/java/tech/ydb/topic/settings/TopicRetryConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package tech.ydb.topic.settings; | ||
|
|
||
| import tech.ydb.common.retry.ExponentialBackoffRetry; | ||
| import tech.ydb.common.retry.RetryConfig; | ||
| import tech.ydb.common.retry.RetryPolicy; | ||
| import tech.ydb.core.Status; | ||
|
|
||
| /** | ||
| * Predefined {@link RetryConfig} instances for topic writers and readers. | ||
| * <p> | ||
| * Pass one of these constants (or a custom {@link RetryConfig}) to | ||
| * {@link WriterSettings.Builder#setRetryConfig} to control how the writer | ||
| * behaves when its underlying stream is interrupted. | ||
| * | ||
| * @author Aleksandr Gorshenin | ||
| */ | ||
| public class TopicRetryConfig { | ||
| // Max backoff will be random delay from 32.768s to 65.536s | ||
| private static final RetryPolicy DEFAULT_BACKOFF = new ExponentialBackoffRetry(32, 10); | ||
|
|
||
| /** | ||
| * Retry any stream disconnection indefinitely with exponential backoff. | ||
| * <p> | ||
| * Every status code, including {@link Status#SUCCESS}, is treated as retryable. | ||
| * The delay between reconnection attempts grows exponentially and is capped at a | ||
| * random value between 32 and 65 seconds. | ||
| * <p> | ||
| * This is the default retry configuration for topic writers and readers. | ||
| */ | ||
| public static final RetryConfig FOREVER = status -> DEFAULT_BACKOFF; | ||
|
alex268 marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * Disable retries entirely. | ||
| * <p> | ||
| * Any stream disconnection is reported immediately as a terminal error through | ||
| * the errors handler configured via | ||
| * {@link WriterSettings.Builder#setErrorsHandler}. | ||
| * Use this when you need full control over reconnection logic in application code. | ||
| */ | ||
| public static final RetryConfig NEVER = status -> null; | ||
|
|
||
| private TopicRetryConfig() { } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.