Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Copy tags from additional query options #276

Merged
merged 1 commit into from
Nov 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/main/java/com/orbitz/consul/cache/ConsulCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,16 @@ protected static QueryOptions watchParams(final BigInteger index, final int bloc
checkArgument(!queryOptions.getIndex().isPresent() && !queryOptions.getWait().isPresent(),
"Index and wait cannot be overridden");

return ImmutableQueryOptions.builder()
ImmutableQueryOptions.Builder builder = ImmutableQueryOptions.builder()
.from(watchDefaultParams(index, blockSeconds))
.token(queryOptions.getToken())
.consistencyMode(queryOptions.getConsistencyMode())
.near(queryOptions.getNear())
.datacenter(queryOptions.getDatacenter())
.build();
.datacenter(queryOptions.getDatacenter());
for (String tag : queryOptions.getTag()) {
builder.addTag(tag);
}
return builder.build();
}

private static QueryOptions watchDefaultParams(final BigInteger index, final int blockSeconds) {
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/com/orbitz/consul/cache/ConsulCacheTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ public void testWatchParamsWithAdditionalOptions() {
BigInteger index = new BigInteger("12");
QueryOptions additionalOptions = ImmutableQueryOptions.builder()
.consistencyMode(ConsistencyMode.STALE)
.addTag("someTag")
.token("186596")
.near("156892")
.build();
Expand All @@ -394,6 +395,7 @@ public void testWatchParamsWithAdditionalOptions() {
.index(index)
.wait("10s")
.consistencyMode(ConsistencyMode.STALE)
.addTag("someTag")
.token("186596")
.near("156892")
.build();
Expand Down