Skip to content

Commit

Permalink
Refactor ClientAttributeOption
Browse files Browse the repository at this point in the history
Co-authored-by: M Sazzadul Hoque <[email protected]>
  • Loading branch information
yangbodong22011 and sazzad16 committed Apr 7, 2023
1 parent 052ac8c commit 91ac203
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/main/java/redis/clients/jedis/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import redis.clients.jedis.Protocol.Command;
import redis.clients.jedis.Protocol.Keyword;
import redis.clients.jedis.args.ClientAttrOption;
import redis.clients.jedis.args.ClientAttributeOption;
import redis.clients.jedis.args.Rawable;
import redis.clients.jedis.commands.ProtocolCommand;
import redis.clients.jedis.exceptions.JedisConnectionException;
Expand Down Expand Up @@ -372,13 +372,13 @@ private void initializeFromClientConfig(JedisClientConfig config) {
String libName = JedisMetaInfo.getArtifactId();
if (libName != null) {
fireAndForgetMsg.add(new CommandArguments(Command.CLIENT).add(Keyword.SETINFO)
.add(ClientAttrOption.LIB_NAME.getRaw()).add(libName));
.add(ClientAttributeOption.LIB_NAME.getRaw()).add(libName));
}

String libVersion = JedisMetaInfo.getVersion();
if (libVersion != null) {
fireAndForgetMsg.add(new CommandArguments(Command.CLIENT).add(Keyword.SETINFO)
.add(ClientAttrOption.LIB_VER.getRaw()).add(libVersion));
.add(ClientAttributeOption.LIB_VER.getRaw()).add(libVersion));
}

for (CommandArguments arg : fireAndForgetMsg) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/redis/clients/jedis/Jedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -4232,7 +4232,7 @@ public byte[] clientInfoBinary() {
}

@Override
public String clientSetInfo(ClientAttrOption attr, byte[] value) {
public String clientSetInfo(ClientAttributeOption attr, byte[] value) {
checkIsInMultiOrPipeline();
connection.sendCommand(CLIENT, SETINFO.getRaw(), attr.getRaw(), value);
return connection.getStatusCodeReply();
Expand Down Expand Up @@ -8522,7 +8522,7 @@ public String clientInfo() {
}

@Override
public String clientSetInfo(ClientAttrOption attr, String value) {
public String clientSetInfo(ClientAttributeOption attr, String value) {
checkIsInMultiOrPipeline();
connection.sendCommand(CLIENT, SETINFO.getRaw(), attr.getRaw(), encode(value));
return connection.getStatusCodeReply();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
* CLIENT SETINFO command attr option
* since redis 7.2
*/
public enum ClientAttrOption implements Rawable {
public enum ClientAttributeOption implements Rawable {
LIB_NAME("LIB-NAME"),
LIB_VER("LIB-VER");

private final byte[] raw;

private ClientAttrOption(String str) {
private ClientAttributeOption(String str) {
this.raw = SafeEncoder.encode(str);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package redis.clients.jedis.commands;

import redis.clients.jedis.args.ClientAttrOption;
import redis.clients.jedis.args.ClientAttributeOption;
import redis.clients.jedis.args.ClientPauseMode;
import redis.clients.jedis.args.ClientType;
import redis.clients.jedis.args.UnblockType;
Expand Down Expand Up @@ -84,7 +84,7 @@ public interface ClientBinaryCommands {
* @param value the value
* @return OK or error
*/
String clientSetInfo(ClientAttrOption attr, byte[] value);
String clientSetInfo(ClientAttributeOption attr, byte[] value);

/**
* Assigns a name to the current connection.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package redis.clients.jedis.commands;

import redis.clients.jedis.args.ClientAttrOption;
import redis.clients.jedis.args.ClientAttributeOption;
import redis.clients.jedis.args.ClientPauseMode;
import redis.clients.jedis.args.ClientType;
import redis.clients.jedis.args.UnblockType;
Expand Down Expand Up @@ -84,7 +84,7 @@ public interface ClientCommands {
* @param value the value
* @return OK or error
*/
String clientSetInfo(ClientAttrOption attr, String value);
String clientSetInfo(ClientAttributeOption attr, String value);

/**
* Assigns a name to the current connection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.junit.Test;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.args.ClientAttrOption;
import redis.clients.jedis.args.ClientAttributeOption;
import redis.clients.jedis.args.ClientType;
import redis.clients.jedis.args.UnblockType;
import redis.clients.jedis.exceptions.JedisConnectionException;
Expand Down Expand Up @@ -68,8 +68,8 @@ public void nameBinary() {
public void clientSetInfoDefault() {
String libName = "jedis";
String libVersion = "999.999.999";
Assert.assertEquals("OK", client.clientSetInfo(ClientAttrOption.LIB_NAME, libName));
Assert.assertEquals("OK", client.clientSetInfo(ClientAttrOption.LIB_VER, libVersion));
Assert.assertEquals("OK", client.clientSetInfo(ClientAttributeOption.LIB_NAME, libName));
Assert.assertEquals("OK", client.clientSetInfo(ClientAttributeOption.LIB_VER, libVersion));
String info = client.clientInfo();
assertTrue(info.contains("lib-name=jedis"));
assertTrue(info.contains("lib-ver=999.999.999"));
Expand Down

0 comments on commit 91ac203

Please sign in to comment.