Skip to content

Commit

Permalink
Spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
jduo committed Jul 4, 2024
1 parent 9311b9a commit f0fd6fe
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 32 deletions.
18 changes: 10 additions & 8 deletions java/client/src/main/java/glide/api/BaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public abstract class BaseClient

/** Redis simple string response with "OK" */
public static final String OK = ConstantResponse.OK.toString();

public static final GlideString TOK = GlideString.of(OK);

protected final CommandManager commandManager;
Expand Down Expand Up @@ -3771,15 +3772,16 @@ public CompletableFuture<String> publish(@NonNull String message, @NonNull Strin
}

@Override
public CompletableFuture<GlideString> publish(@NonNull GlideString message, @NonNull GlideString channel) {
public CompletableFuture<GlideString> publish(
@NonNull GlideString message, @NonNull GlideString channel) {
return commandManager.submitNewCommand(
Publish,
new GlideString[] {channel, message},
response -> {
// Check, but ignore the number - it is never valid. A GLIDE bug/limitation TODO
handleLongResponse(response);
return TOK;
});
Publish,
new GlideString[] {channel, message},
response -> {
// Check, but ignore the number - it is never valid. A GLIDE bug/limitation TODO
handleLongResponse(response);
return TOK;
});
}

@Override
Expand Down
16 changes: 8 additions & 8 deletions java/client/src/main/java/glide/api/RedisClusterClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1006,19 +1006,19 @@ public CompletableFuture<String> publish(

@Override
public CompletableFuture<GlideString> publish(
@NonNull GlideString message, @NonNull GlideString channel, boolean sharded) {
@NonNull GlideString message, @NonNull GlideString channel, boolean sharded) {
if (!sharded) {
return publish(message, channel);
}

return commandManager.submitNewCommand(
SPublish,
new GlideString[] {channel, message},
response -> {
// Check, but ignore the number - it is never valid. A GLIDE bug/limitation TODO
handleLongResponse(response);
return TOK;
});
SPublish,
new GlideString[] {channel, message},
response -> {
// Check, but ignore the number - it is never valid. A GLIDE bug/limitation TODO
handleLongResponse(response);
return TOK;
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */
package glide.api.commands;

import java.util.concurrent.CompletableFuture;

import glide.api.models.GlideString;
import java.util.concurrent.CompletableFuture;

/**
* Supports commands for the "Pub/Sub" group for standalone and cluster clients.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */
package glide.api.commands;

import java.util.concurrent.CompletableFuture;

import glide.api.models.GlideString;
import java.util.concurrent.CompletableFuture;

/**
* Supports commands for the "Pub/Sub" group for a cluster client.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import glide.api.models.configuration.StandaloneSubscriptionConfiguration.PubSubChannelMode;
import glide.api.models.configuration.StandaloneSubscriptionConfiguration.StandaloneSubscriptionConfigurationBuilder;
import glide.api.models.exceptions.ConfigurationError;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -72,7 +71,7 @@ public abstract static class BaseSubscriptionConfigurationBuilder<
protected Optional<Object> context = Optional.empty();

protected <M extends ChannelMode> void addSubscription(
Map<M, Set<GlideString>> subscriptions, M mode, GlideString channelOrPattern) {
Map<M, Set<GlideString>> subscriptions, M mode, GlideString channelOrPattern) {
if (!subscriptions.containsKey(mode)) {
// Note: Use a LinkedHashSet to preserve order for ease of debugging and unit testing.
subscriptions.put(mode, new LinkedHashSet<>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
package glide.api.models.configuration;

import glide.api.RedisClusterClient;
import glide.api.models.GlideString;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

import glide.api.models.GlideString;
import lombok.Getter;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
package glide.api.models.configuration;

import glide.api.RedisClient;
import glide.api.models.GlideString;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

import glide.api.models.GlideString;
import lombok.Getter;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static glide.api.models.GlideString.gs;

import glide.api.logging.Logger;
import glide.api.models.GlideString;
import glide.api.models.PubSubMessage;
import glide.api.models.configuration.BaseSubscriptionConfiguration.MessageCallback;
import glide.api.models.exceptions.RedisException;
Expand Down Expand Up @@ -62,7 +61,9 @@ public void handle(Response response) {
"Transport disconnected, messages might be lost");
break;
case PMessage:
handle(new PubSubMessage(gs((String) values[2]), gs((String) values[1]), gs((String) values[0])));
handle(
new PubSubMessage(
gs((String) values[2]), gs((String) values[1]), gs((String) values[0])));
return;
case Message:
case SMessage:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,15 @@ public void connection_request_protobuf_generation_with_all_fields_set() {
Map.of(
EXACT.ordinal(),
PubSubChannelsOrPatterns.newBuilder()
.addChannelsOrPatterns(ByteString.copyFrom(gs("channel_1").getBytes()))
.addChannelsOrPatterns(ByteString.copyFrom(gs("channel_2").getBytes()))
.addChannelsOrPatterns(
ByteString.copyFrom(gs("channel_1").getBytes()))
.addChannelsOrPatterns(
ByteString.copyFrom(gs("channel_2").getBytes()))
.build(),
PATTERN.ordinal(),
PubSubChannelsOrPatterns.newBuilder()
.addChannelsOrPatterns(ByteString.copyFrom(gs("*chatRoom*").getBytes()))
.addChannelsOrPatterns(
ByteString.copyFrom(gs("*chatRoom*").getBytes()))
.build()))
.build())
.build();
Expand Down
5 changes: 4 additions & 1 deletion java/integTest/src/test/java/glide/PubSubTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ public void pattern(boolean standalone, boolean useCallback) {
GlideString pattern = gs(prefix + "*");
Map<GlideString, GlideString> message2channels =
Map.of(
gs(prefix + "1"), gs(UUID.randomUUID().toString()), gs(prefix + "2"), gs(UUID.randomUUID().toString()));
gs(prefix + "1"),
gs(UUID.randomUUID().toString()),
gs(prefix + "2"),
gs(UUID.randomUUID().toString()));
var subscriptions =
Map.of(
standalone ? PubSubChannelMode.PATTERN : PubSubClusterChannelMode.PATTERN,
Expand Down

0 comments on commit f0fd6fe

Please sign in to comment.