-
Notifications
You must be signed in to change notification settings - Fork 991
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register library name and library version on Redis 7.2 or greater #2483
RedisURI now accepts library name and library version and sets those after the handshake.
- Loading branch information
Showing
14 changed files
with
484 additions
and
46 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright 2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.lettuce.core; | ||
|
||
/** | ||
* @author Mark Paluch | ||
*/ | ||
class ConnectionMetadata { | ||
|
||
private volatile String clientName; | ||
|
||
private volatile String libraryName; | ||
|
||
private volatile String libraryVersion; | ||
|
||
public ConnectionMetadata() { | ||
} | ||
|
||
public ConnectionMetadata(RedisURI uri) { | ||
apply(uri); | ||
} | ||
|
||
public void apply(RedisURI redisURI) { | ||
|
||
setClientName(redisURI.getClientName()); | ||
setLibraryName(redisURI.getLibraryName()); | ||
setLibraryVersion(redisURI.getLibraryVersion()); | ||
} | ||
|
||
public void apply(ConnectionMetadata metadata) { | ||
|
||
setClientName(metadata.getClientName()); | ||
setLibraryName(metadata.getLibraryName()); | ||
setLibraryVersion(metadata.getLibraryVersion()); | ||
} | ||
|
||
protected void setClientName(String clientName) { | ||
this.clientName = clientName; | ||
} | ||
|
||
String getClientName() { | ||
return clientName; | ||
} | ||
|
||
void setLibraryName(String libraryName) { | ||
this.libraryName = libraryName; | ||
} | ||
|
||
String getLibraryName() { | ||
return libraryName; | ||
} | ||
|
||
void setLibraryVersion(String libraryVersion) { | ||
this.libraryVersion = libraryVersion; | ||
} | ||
|
||
String getLibraryVersion() { | ||
return libraryVersion; | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.lettuce.core; | ||
|
||
/** | ||
* Class that exposes the Lettuce version. Fetches the "Implementation-Version" manifest attribute from the jar file. | ||
* <p> | ||
* Note that some ClassLoaders do not expose the package metadata, hence this class might not be able to determine the Lettuce | ||
* version in all environments. Consider using a reflection-based check instead — for example, checking for the presence | ||
* of a specific Lettuce method that you intend to call. | ||
* | ||
* @author Mark Paluch | ||
* @since 6.3 | ||
*/ | ||
public final class LettuceVersion { | ||
|
||
private LettuceVersion() { | ||
} | ||
|
||
/** | ||
* Return the library name. | ||
*/ | ||
public static String getName() { | ||
return "Lettuce"; | ||
} | ||
|
||
/** | ||
* Return the full version string of the present Lettuce codebase, or {@code null} if it cannot be determined. | ||
* | ||
* @see Package#getImplementationVersion() | ||
*/ | ||
public static String getVersion() { | ||
Package pkg = LettuceVersion.class.getPackage(); | ||
return (pkg != null ? pkg.getImplementationVersion() : 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
Oops, something went wrong.