-
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
Remove validation when adding or updating consumer #923
Conversation
scottf
commented
Jun 13, 2023
•
edited
edited
- Do not require name or durable when adding or updating a consumer.
- Do not reject when inactive threshold is set and a durable is set.
@@ -654,12 +654,19 @@ public void testAddDeleteConsumer() throws Exception { | |||
assertTrue(iae.getMessage().contains("Stream cannot be null or empty")); | |||
iae = assertThrows(IllegalArgumentException.class, () -> jsm.addOrUpdateConsumer(STREAM, null)); | |||
assertTrue(iae.getMessage().contains("Config cannot be null")); | |||
iae = assertThrows(IllegalArgumentException.class, () -> jsm.addOrUpdateConsumer(STREAM, cc)); | |||
assertTrue(iae.getMessage().contains("Durable cannot be null")); |
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.
No longer validating
|
||
// durable and name can both be null | ||
ConsumerInfo ci = jsm.addOrUpdateConsumer(STREAM, cc); | ||
assertNotNull(ci.getName()); |
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.
test that the server gives a name when one is not supplied
iae = assertThrows(IllegalArgumentException.class, () -> jsm.addOrUpdateConsumer(STREAM, cc2)); | ||
assertTrue(iae.getMessage().contains("Inactive Threshold")); | ||
ci = jsm.addOrUpdateConsumer(STREAM, cc2); | ||
assertEquals(10000, ci.getConsumerConfiguration().getInactiveThreshold().toMillis()); |
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.
test that an inactiveThreshold is allowed when a durable name is supplied
@@ -125,11 +124,6 @@ public PurgeResponse purgeStream(String streamName, PurgeOptions options) throws | |||
public ConsumerInfo addOrUpdateConsumer(String streamName, ConsumerConfiguration config) throws IOException, JetStreamApiException { | |||
validateStreamName(streamName, true); | |||
validateNotNull(config, "Config"); | |||
validateNotNull(config.getDurable(), "Durable"); // durable name is required when creating consumers |
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.
durable not required
Duration d = config.getInactiveThreshold(); | ||
if (d != null && !d.isZero()) { | ||
throw new IllegalArgumentException("Durable consumers cannot have an Inactive Threshold."); | ||
} |
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.
inactiveThreshold allowed even when there is a durable
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.
Looks good, just one nit
@@ -106,13 +113,33 @@ public final synchronized String next() { | |||
// copy in the seq in base36. |
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.
Should say base62 I think.
// copy in the seq in base36. | |
// copy in the seq in base62. |
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.
heh, that was a copy from the method I based this on. Fixing
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!