Skip to content

Commit

Permalink
Use GREATER_THAN constant (#1174)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottf authored Jul 6, 2024
1 parent 197c04f commit d695873
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import static io.nats.client.support.JsonUtils.beginJson;
import static io.nats.client.support.JsonUtils.endJson;
import static io.nats.client.support.JsonValueUtils.*;
import static io.nats.client.support.NatsJetStreamConstants.DEFAULT_FILTER_SUBJECT;
import static io.nats.client.support.NatsConstants.GREATER_THAN;
import static io.nats.client.support.Validator.emptyAsNull;

public class OrderedConsumerConfiguration implements JsonSerializable {
Expand All @@ -45,7 +45,7 @@ public class OrderedConsumerConfiguration implements JsonSerializable {
public OrderedConsumerConfiguration() {
startSequence = ConsumerConfiguration.LONG_UNSET;
filterSubjects = new ArrayList<>();
filterSubjects.add(DEFAULT_FILTER_SUBJECT);
filterSubjects.add(GREATER_THAN);
}

public OrderedConsumerConfiguration(String json) throws JsonParseException {
Expand Down Expand Up @@ -118,7 +118,7 @@ public OrderedConsumerConfiguration filterSubjects(List<String> filterSubjects)
}
}
if (this.filterSubjects.isEmpty()) {
this.filterSubjects.add(DEFAULT_FILTER_SUBJECT);
this.filterSubjects.add(GREATER_THAN);
}
return this;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/nats/client/api/StreamInfoOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static io.nats.client.support.ApiConstants.DELETED_DETAILS;
import static io.nats.client.support.ApiConstants.SUBJECTS_FILTER;
import static io.nats.client.support.JsonUtils.*;
import static io.nats.client.support.NatsConstants.GREATER_THAN;
import static io.nats.client.support.Validator.emptyAsNull;

/**
Expand Down Expand Up @@ -110,7 +111,7 @@ public Builder filterSubjects(String subjectsFilter) {
* @return the builder
*/
public Builder allSubjects() {
this.subjectsFilter = ">";
this.subjectsFilter = GREATER_THAN;
return this;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/nats/client/impl/NatsJetStreamImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

import static io.nats.client.support.NatsConstants.GT;
import static io.nats.client.support.NatsConstants.GREATER_THAN;
import static io.nats.client.support.NatsJetStreamClientError.JsConsumerCreate290NotAvailable;
import static io.nats.client.support.NatsJetStreamClientError.JsMultipleFilterSubjects210NotAvailable;
import static io.nats.client.support.NatsRequestCompletableFuture.CancelAction;
Expand Down Expand Up @@ -104,7 +104,7 @@ ConsumerInfo _createConsumer(String streamName, ConsumerConfiguration config, Co
consumerName = durable == null ? generateConsumerName() : durable;
}
String fs = config.getFilterSubject(); // we've already determined not multiple so this gives us 1 or null
if (fs == null || fs.equals(GT)) {
if (fs == null || fs.equals(GREATER_THAN)) {
subj = String.format(JSAPI_CONSUMER_CREATE_V290, streamName, consumerName);
}
else {
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/io/nats/client/impl/NatsKeyValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import java.util.concurrent.LinkedBlockingQueue;

import static io.nats.client.support.NatsConstants.DOT;
import static io.nats.client.support.NatsJetStreamConstants.*;
import static io.nats.client.support.NatsConstants.GREATER_THAN;
import static io.nats.client.support.NatsJetStreamConstants.EXPECTED_LAST_SUB_SEQ_HDR;
import static io.nats.client.support.NatsJetStreamConstants.JS_WRONG_LAST_SEQUENCE;
import static io.nats.client.support.NatsKeyValueUtil.*;
import static io.nats.client.support.Validator.*;

Expand Down Expand Up @@ -266,20 +268,20 @@ public NatsKeyValueWatchSubscription watch(List<String> keys, KeyValueWatcher wa

@Override
public NatsKeyValueWatchSubscription watchAll(KeyValueWatcher watcher, KeyValueWatchOption... watchOptions) throws IOException, JetStreamApiException, InterruptedException {
return new NatsKeyValueWatchSubscription(this, Collections.singletonList(">"), watcher, -1, watchOptions);
return new NatsKeyValueWatchSubscription(this, Collections.singletonList(GREATER_THAN), watcher, -1, watchOptions);
}

@Override
public NatsKeyValueWatchSubscription watchAll(KeyValueWatcher watcher, long fromRevision, KeyValueWatchOption... watchOptions) throws IOException, JetStreamApiException, InterruptedException {
return new NatsKeyValueWatchSubscription(this, Collections.singletonList(">"), watcher, fromRevision, watchOptions);
return new NatsKeyValueWatchSubscription(this, Collections.singletonList(GREATER_THAN), watcher, fromRevision, watchOptions);
}

/**
* {@inheritDoc}
*/
@Override
public List<String> keys() throws IOException, JetStreamApiException, InterruptedException {
return _keys(Collections.singletonList(readSubject(DEFAULT_FILTER_SUBJECT)));
return _keys(Collections.singletonList(readSubject(GREATER_THAN)));
}

@Override
Expand Down Expand Up @@ -312,7 +314,7 @@ private List<String> _keys(List<String> readSubjectFilters) throws IOException,
*/
@Override
public LinkedBlockingQueue<KeyResult> consumeKeys() {
return _consumeKeys(Collections.singletonList(readSubject(DEFAULT_FILTER_SUBJECT)));
return _consumeKeys(Collections.singletonList(readSubject(GREATER_THAN)));
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/nats/client/impl/NatsObjectStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Arrays;
import java.util.List;

import static io.nats.client.support.NatsConstants.GREATER_THAN;
import static io.nats.client.support.NatsJetStreamClientError.*;
import static io.nats.client.support.NatsObjectStoreUtil.*;

Expand Down Expand Up @@ -73,7 +74,7 @@ String rawMetaSubject(String name) {
}

String rawAllMetaSubject() {
return rawMetaPrefix + ">";
return rawMetaPrefix + GREATER_THAN;
}

String pubSubMetaSubject(String name) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/nats/client/support/NatsConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public interface NatsConstants {
String EMPTY = "";
String CRLF = "\r\n";
String DOT = ".";
String GT = ">";
String GREATER_THAN = ">";
String STAR = "*";

byte TAB = '\t';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,4 @@ public interface NatsJetStreamConstants {
int JS_CONSUMER_NOT_FOUND_ERR = 10014;
int JS_NO_MESSAGE_FOUND_ERR = 10037;
int JS_WRONG_LAST_SEQUENCE = 10071;

String DEFAULT_FILTER_SUBJECT = ">";
}
3 changes: 2 additions & 1 deletion src/main/java/io/nats/service/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Objects;

import static io.nats.client.support.NatsConstants.DOT;
import static io.nats.client.support.NatsConstants.GREATER_THAN;
import static io.nats.client.support.Validator.emptyAsNull;

/**
Expand All @@ -38,7 +39,7 @@ public Group(String name) {
throw new IllegalArgumentException("Group name cannot be null or empty.");
}

if (name.contains(">")) {
if (name.contains(GREATER_THAN)) {
throw new IllegalArgumentException("Group name cannot contain '>'.");
}

Expand Down

0 comments on commit d695873

Please sign in to comment.