-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend CLIENT SETINFO support (#3509)
* Extend CLIENT SETINFO support * Modify JedisMetaInfo * Fix custom lib name and ver * Remove version suffix * Separate ClientSetInfoConfig * Address braces * Rename method to isDisabled
- Loading branch information
Showing
8 changed files
with
196 additions
and
50 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/main/java/redis/clients/jedis/ClientSetInfoConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package redis.clients.jedis; | ||
|
||
/** | ||
* This interface is to modify the behavior of internally executing CLIENT SETINFO command. | ||
*/ | ||
public interface ClientSetInfoConfig { | ||
|
||
default boolean isDisabled() { | ||
return false; | ||
} | ||
|
||
/** | ||
* If provided, this suffix will be enclosed by braces {@code ()}. | ||
*/ | ||
default String getLibNameSuffix() { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/main/java/redis/clients/jedis/DefaultClientSetInfoConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package redis.clients.jedis; | ||
|
||
public final class DefaultClientSetInfoConfig implements ClientSetInfoConfig { | ||
|
||
private final boolean disabled; | ||
|
||
private final String libNameSuffix; | ||
|
||
private DefaultClientSetInfoConfig(boolean disabled, String libNameSuffix) { | ||
this.disabled = disabled; | ||
this.libNameSuffix = libNameSuffix; | ||
} | ||
|
||
@Override | ||
public boolean isDisabled() { | ||
return disabled; | ||
} | ||
|
||
@Override | ||
public String getLibNameSuffix() { | ||
return libNameSuffix; | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static class Builder { | ||
|
||
private boolean disable = false; | ||
|
||
private String libNameSuffix = null; | ||
|
||
private Builder() { | ||
} | ||
|
||
public DefaultClientSetInfoConfig build() { | ||
if (disable) { | ||
if (libNameSuffix != null) { | ||
throw new IllegalArgumentException("libNameSuffix cannot be used when internal " | ||
+ "CLIENT SETINFO command is disabled."); | ||
} | ||
} | ||
|
||
return new DefaultClientSetInfoConfig(disable, libNameSuffix); | ||
} | ||
|
||
public Builder disable() { | ||
return disable(true); | ||
} | ||
|
||
public Builder disable(boolean disable) { | ||
this.disable = disable; | ||
return this; | ||
} | ||
|
||
public Builder libNameSuffix(String suffix) { | ||
this.libNameSuffix = suffix; | ||
return this; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters