-
Notifications
You must be signed in to change notification settings - Fork 150
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
Kv parity issues 94, 95, 96 #599
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
4f07e7f
kv updated delivery policy and pending! instead of getLastMessage for…
scottf e5d977e
kv updated delivery policy and pending! instead of getLastMessage for…
scottf 4ebf19d
kv updated delivery policy and pending! instead of getLastMessage for…
scottf 915bab8
shoring up test coverage
scottf eae97ca
shoring up test coverage
scottf 2ad90d2
Merge branch 'main' into kv-updates-issue-94
scottf d54f8ab
shoring up test coverage
scottf eee3db0
shoring up test coverage
scottf e180db1
issue 96 purge deletes
scottf 0dd4ad8
issue 96 purge deletes fix test
scottf 349843f
issue 95 use of prefix as specified in ADR
scottf ef4fdbe
issue 95 use of prefix as specified in ADR
scottf 8c12d93
updated licence
scottf 780b964
Merge branch 'main' into kv-updates-issue-94
scottf 38cb5af
Merge branch 'main' into kv-updates-issue-94
scottf b352a52
doh missing last line in files
scottf 29cdbab
Merge remote-tracking branch 'origin/kv-updates-issue-94' into kv-upd…
scottf 4c23814
Merge branch 'main' into kv-updates-issue-94
scottf 0089a72
Merge branch 'main' into kv-updates-issue-94
scottf 6163bf9
Merge branch 'main' into kv-updates-issue-94
scottf b2b1a59
Merge branch 'main' into kv-updates-issue-94
scottf 51a81dd
addressed comments
scottf File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 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 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 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
105 changes: 105 additions & 0 deletions
105
src/main/java/io/nats/client/api/KeyValuePurgeOptions.java
This file contains 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,105 @@ | ||
// Copyright 2022 The NATS Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at: | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package io.nats.client.api; | ||
|
||
import java.time.Duration; | ||
|
||
public class KeyValuePurgeOptions { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need doc? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, will do |
||
|
||
/** | ||
* The default time in millis that is used for as the threshold to keep markers. | ||
*/ | ||
public static long DEFAULT_THRESHOLD_MILLIS = Duration.ofMinutes(30).toMillis(); | ||
|
||
private final long deleteMarkersThresholdMillis; | ||
|
||
private KeyValuePurgeOptions(Builder b) { | ||
this.deleteMarkersThresholdMillis = b.deleteMarkersThresholdMillis; | ||
} | ||
|
||
/** | ||
* The value of the delete marker threshold, in milliseconds. | ||
* @return the threshold | ||
*/ | ||
public long getDeleteMarkersThresholdMillis() { | ||
return deleteMarkersThresholdMillis; | ||
} | ||
|
||
/** | ||
* Creates a builder for the Key Value Purge Options. | ||
* @return a key value purge options builder | ||
*/ | ||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
/** | ||
* KeyValuePurgeOptions is created using a Builder. The builder supports chaining and will | ||
* create a default set of options if no methods are calls. | ||
* | ||
* <p>{@code new KeyValuePurgeOptions.Builder().build()} will create a new KeyValuePurgeOptions. | ||
* | ||
*/ | ||
public static class Builder { | ||
private long deleteMarkersThresholdMillis = DEFAULT_THRESHOLD_MILLIS; | ||
|
||
/** | ||
* Set the delete marker threshold. | ||
* Null or duration of 0 will assume the default threshold {@link #DEFAULT_THRESHOLD_MILLIS} | ||
* Duration less than zero will assume no threshold and will not keep any markers. | ||
* @param deleteMarkersThreshold the threshold duration or null | ||
* @return The builder | ||
*/ | ||
public Builder deleteMarkersThreshold(Duration deleteMarkersThreshold) { | ||
this.deleteMarkersThresholdMillis = deleteMarkersThreshold == null | ||
? DEFAULT_THRESHOLD_MILLIS : deleteMarkersThreshold.toMillis(); | ||
return this; | ||
} | ||
|
||
/** | ||
* Set the delete marker threshold. | ||
* 0 will assume the default threshold {@link #DEFAULT_THRESHOLD_MILLIS} | ||
* Less than zero will assume no threshold and will not keep any markers. | ||
* @param deleteMarkersThresholdMillis the threshold millis | ||
* @return The builder | ||
*/ | ||
public Builder deleteMarkersThreshold(long deleteMarkersThresholdMillis) { | ||
this.deleteMarkersThresholdMillis = deleteMarkersThresholdMillis; | ||
return this; | ||
} | ||
|
||
/** | ||
* Set the delete marker threshold to -1 so as to not keep any markers | ||
* @return The builder | ||
*/ | ||
public Builder deleteMarkersNoThreshold() { | ||
this.deleteMarkersThresholdMillis = -1; | ||
return this; | ||
} | ||
|
||
/** | ||
* Build the Key Value Purge Options | ||
* @return the options | ||
*/ | ||
public KeyValuePurgeOptions build() { | ||
if (deleteMarkersThresholdMillis < 0) { | ||
deleteMarkersThresholdMillis = -1; | ||
} | ||
else if (deleteMarkersThresholdMillis == 0) { | ||
deleteMarkersThresholdMillis = DEFAULT_THRESHOLD_MILLIS; | ||
} | ||
return new KeyValuePurgeOptions(this); | ||
} | ||
} | ||
} |
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.
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.
Can remove the BETA FEATURE comments if PR makes the KV API GA. Alternatively, that could be another PR - up to you.
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.
I'll do it on another PR