Skip to content
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

Merged
merged 10 commits into from
Jun 14, 2023

Conversation

scottf
Copy link
Contributor

@scottf scottf commented Jun 13, 2023

  1. Do not require name or durable when adding or updating a consumer.
  2. 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"));
Copy link
Contributor Author

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());
Copy link
Contributor Author

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());
Copy link
Contributor Author

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
Copy link
Contributor Author

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.");
}
Copy link
Contributor Author

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

Copy link
Contributor

@piotrpio piotrpio left a 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.
Copy link
Contributor

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.

Suggested change
// copy in the seq in base36.
// copy in the seq in base62.

Copy link
Contributor Author

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

@scottf scottf requested a review from piotrpio June 14, 2023 12:22
Copy link
Contributor

@piotrpio piotrpio left a comment

Choose a reason for hiding this comment

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

LGTM!

@scottf scottf merged commit 4f3ca27 into main Jun 14, 2023
2 checks passed
@scottf scottf deleted the add-consumer-remove-validation branch June 14, 2023 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants