-
Notifications
You must be signed in to change notification settings - Fork 55
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
Prevent KeyValueStore error when MaxAge is set below the default DuplicateWindow value #362
Conversation
Our general policy is not to fix validation issues but throw validation exception. |
Interesting. I wouldn't expect JS exceptions when operating with the K/V store. But, can fix on my end. No problem. This would effectively limit MaxAge to >2min. Anything less than this would result in an error. |
I didn't mean to close the PR. it's a good use case. Edit: Apologies, you're right! 👇 |
Actually what you've done seems to be the correct thing: I didn't realised duplicate window wasn't actually part of KV config. |
…icateWindow value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks @rickdotnet 💯
@@ -108,9 +108,13 @@ public async ValueTask<INatsKVStore> CreateStoreAsync(NatsKVConfig config, Cance | |||
// MirrorDirect = | |||
// Mirror = | |||
Retention = StreamConfigRetention.Limits, // from ADR-8 | |||
DuplicateWindow = TimeSpan.FromMinutes(2), // 120_000_000_000ns, from ADR-8 | |||
DuplicateWindow = config.MaxAge != default ? config.MaxAge : TimeSpan.FromMinutes(2), // 120_000_000_000ns, from ADR-8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my fault didn't check setting duplicate-window to max-age here should've been removed
- DuplicateWindow = config.MaxAge != default ? config.MaxAge : TimeSpan.FromMinutes(2), // 120_000_000_000ns, from ADR-8
+ DuplicateWindow = TimeSpan.FromMinutes(2), // 120_000_000_000ns, from ADR-8
cc @scottf
Background: When setting max age default window is always set equals to max age. e.g. if we set max-age=30 minute default windows should still stay at 2 minutes.
When setting a MaxAge less than the default DuplicateWindow value, you receive the following error. This PR fixes this.
Modified
Example.KeyValueStore.Watcher
code to reproduce: