Skip to content

Commit

Permalink
Merge branch 'main' into node/integ_cyip10_bitpos
Browse files Browse the repository at this point in the history
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
  • Loading branch information
Yury-Fridlyand committed Sep 16, 2024
2 parents a7926c8 + 44174a3 commit 4daa3f0
Show file tree
Hide file tree
Showing 38 changed files with 2,384 additions and 564 deletions.
51 changes: 42 additions & 9 deletions .github/workflows/java-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,25 @@ jobs:
echo "Deployment ${{ env.DEPLOYMENT_ID }} was unsuccessful with status $DEPLOYMENT_STATUS"
exit 1
test-deployment-on-all-architectures:
needs: [set-release-version, load-platform-matrix, publish-to-maven-central-deployment]
env:
JAVA_VERSION: "11"
RELEASE_VERSION: ${{ needs.set-release-version.outputs.RELEASE_VERSION }}
strategy:
# Run all jobs
fail-fast: false
matrix:
host: ${{ fromJson(needs.load-platform-matrix.outputs.PLATFORM_MATRIX) }}

runs-on: ${{ matrix.host.RUNNER }}
steps:
- name: Start Valkey server
uses: ./.github/actions/install-valkey
with:
engine-version: "7.2.5"
target: ${{ matrix.host.TARGET }}

- uses: actions/checkout@v4
with:
submodules: recursive
Expand All @@ -219,7 +238,14 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "11"
java-version: ${{ env.JAVA_VERSION }}

- name: Install shared software dependencies
uses: ./.github/workflows/install-shared-dependencies
with:
os: ${{ matrix.host.OS }}
target: ${{ matrix.host.TARGET }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install protoc (protobuf)
uses: arduino/setup-protoc@v3
Expand All @@ -235,16 +261,9 @@ jobs:
export GLIDE_RELEASE_VERSION=${{ env.RELEASE_VERSION }}
./gradlew :benchmarks:run --args="--minimal --clients glide"
- name: Drop deployment if validation fails
if: ${{ failure() }}
run: |
curl --request DELETE \
-u "${{ secrets.CENTRAL_TOKEN_USERNAME }}:${{ secrets.CENTRAL_TOKEN_PASSWORD }}" \
"https://central.sonatype.com/api/v1/publisher/deployment/${{ env.DEPLOYMENT_ID }}"
publish-release-to-maven:
if: ${{ inputs.maven_publish == true || github.event_name == 'push' }}
needs: [publish-to-maven-central-deployment]
needs: [test-deployment-on-all-architectures]
runs-on: ubuntu-latest
environment: AWS_ACTIONS
env:
Expand All @@ -255,3 +274,17 @@ jobs:
curl --request POST \
-u "${{ secrets.CENTRAL_TOKEN_USERNAME }}:${{ secrets.CENTRAL_TOKEN_PASSWORD }}" \
"https://central.sonatype.com/api/v1/publisher/deployment/${{ env.DEPLOYMENT_ID }}"
drop-deployment-if-validation-fails:
if: ${{ failure() }}
needs: [publish-to-maven-central-deployment, test-deployment-on-all-architectures]
runs-on: ubuntu-latest
env:
DEPLOYMENT_ID: ${{ needs.publish-to-maven-central-deployment.outputs.DEPLOYMENT_ID }}
steps:
- name: Drop deployment if validation fails
run: |
curl --request DELETE \
-u "${{ secrets.CENTRAL_TOKEN_USERNAME }}:${{ secrets.CENTRAL_TOKEN_PASSWORD }}" \
"https://central.sonatype.com/api/v1/publisher/deployment/${{ env.DEPLOYMENT_ID }}"
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#### Changes
* Node: Fix BITPOS for Valkey8 ([#2227](https://github.com/valkey-io/valkey-glide/pull/2227))
* Node: Use `options` struct for all optional arguments ([#2287](https://github.com/valkey-io/valkey-glide/pull/2287))
* Node: Added `invokeScript` API with routing for cluster client ([#2284](https://github.com/valkey-io/valkey-glide/pull/2284))
* Java: Expanded tests for converting non UTF-8 bytes to Strings ([#2286](https://github.com/valkey-io/valkey-glide/pull/2286))
* Python: Replace instances of Redis with Valkey ([#2266](https://github.com/valkey-io/valkey-glide/pull/2266))
* Java: Replace instances of Redis with Valkey ([#2268](https://github.com/valkey-io/valkey-glide/pull/2268))
* Node: Replace instances of Redis with Valkey ([#2260](https://github.com/valkey-io/valkey-glide/pull/2260))
* Java: Fetch server version using info command ([#2258](https://github.com/valkey-io/valkey-glide/pull/2258))
* Node: Added binary variant for commands which have `Record` as input or output ([#2207](https://github.com/valkey-io/valkey-glide/pull/2207))
* Node: Renamed `ReturnType` to `GlideReturnType` ([#2241](https://github.com/valkey-io/valkey-glide/pull/2241))
* Node, Python: Rename `stop` to `end` in sorted set queries ([#2214](https://github.com/valkey-io/valkey-glide/pull/2214))
Expand Down Expand Up @@ -124,6 +125,7 @@
* Java, Node, Python: Change BITCOUNT end param to optional (Valkey-8) ([#2248](https://github.com/valkey-io/valkey-glide/pull/2248))
* Java, Node, Python: Add NOSCORES option to ZSCAN & NOVALUES option to HSCAN (Valkey-8) ([#2174](https://github.com/valkey-io/valkey-glide/pull/2174))
* Node: Add SCAN command ([#2257](https://github.com/valkey-io/valkey-glide/pull/2257))
* Java: Add Script commands ([#2261](https://github.com/valkey-io/valkey-glide/pull/2261))

#### Breaking Changes
* Java: Update INFO command ([#2274](https://github.com/valkey-io/valkey-glide/pull/2274))
Expand All @@ -139,6 +141,9 @@
* Python: Fix `XClaim` return type to `List[bytes]` instead of `List[TEncodable]` ([#2075](https://github.com/valkey-io/valkey-glide/pull/2075))

### Operational Enhancements
* CI/CD: Create Workflow to deploy artifacts for all platforms ([#2285](https://github.com/valkey-io/valkey-glide/pull/2285)
* Node: Get valkey/redis version using client's info command ([#2276](https://github.com/valkey-io/valkey-glide/pull/2276))
* Java: Fetch server version using client's info command ([#2258](https://github.com/valkey-io/valkey-glide/pull/2258))
* CI/CD: Add workflow for automating Maven release ([#2128](https://github.com/valkey-io/valkey-glide/pull/2128))

## 1.0.0 (2024-07-09)
Expand Down
29 changes: 8 additions & 21 deletions glide-core/src/client/value_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,9 @@ pub(crate) fn convert_to_expected_type(
let result = map
.into_iter()
.map(|(key, inner_value)| {
let key_str = match key {
Value::BulkString(_) => key,
_ => Value::BulkString(from_owned_redis_value::<String>(key)?.into()),
};
match inner_value {
Value::BulkString(_) => Ok((
key_str,
Value::Double(from_owned_redis_value::<f64>(inner_value)?),
)),
Value::Double(_) => Ok((key_str, inner_value)),
_ => Err((
ErrorKind::TypeError,
"Response couldn't be converted to map of {string: double}",
format!("(response was {:?})", get_value_type(&inner_value)),
)
.into()),
}
let key_str = convert_to_expected_type(key, Some(ExpectedReturnType::BulkString)).unwrap();
let value_converted = convert_to_expected_type(inner_value, Some(ExpectedReturnType::Double)).unwrap();
Ok((key_str, value_converted))
})
.collect::<RedisResult<_>>();

Expand Down Expand Up @@ -141,9 +127,10 @@ pub(crate) fn convert_to_expected_type(
)
.into()),
},
ExpectedReturnType::BulkString => Ok(Value::BulkString(
from_owned_redis_value::<String>(value)?.into(),
)),
ExpectedReturnType::BulkString => match value {
Value::BulkString(_) => Ok(value),
_ => Ok(Value::BulkString(from_owned_redis_value::<String>(value)?.into())),
},
ExpectedReturnType::SimpleString => Ok(Value::SimpleString(
from_owned_redis_value::<String>(value)?,
)),
Expand Down Expand Up @@ -340,7 +327,7 @@ pub(crate) fn convert_to_expected_type(
//
// Example:
// let input = ["key", "val1", "val2"]
// let expected =("key", vec!["val1", "val2"])
// let output = ("key", vec!["val1", "val2"])
ExpectedReturnType::ArrayOfStringAndArrays => match value {
Value::Nil => Ok(value),
Value::Array(array) if array.len() == 2 && matches!(array[1], Value::Array(_)) => {
Expand Down
17 changes: 13 additions & 4 deletions go/benchmarks/benchmarking.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ func executeBenchmarks(runConfig *runConfiguration, connectionSettings *connecti
return nil
}

var key_count int64 = 1

func runSingleBenchmark(config *benchmarkConfig) error {
fmt.Printf("Running benchmarking for %s client:\n", config.clientName)
fmt.Printf(
Expand Down Expand Up @@ -228,13 +230,13 @@ const (
func getActions(dataSize int) map[string]operations {
actions := map[string]operations{
getExisting: func(client benchmarkClient) (string, error) {
return client.get(keyFromExistingKeyspace())
return client.get(keyFromExistingKeyspace(getExisting))
},
getNonExisting: func(client benchmarkClient) (string, error) {
return client.get(keyFromNewKeyspace())
},
set: func(client benchmarkClient) (string, error) {
return client.set(keyFromExistingKeyspace(), strings.Repeat("0", dataSize))
return client.set(keyFromExistingKeyspace(set), strings.Repeat("0", dataSize))
},
}

Expand All @@ -246,8 +248,15 @@ const (
sizeExistingKeyspace = 3000000
)

func keyFromExistingKeyspace() string {
randNum, err := rand.Int(rand.Reader, big.NewInt(sizeExistingKeyspace))
func keyFromExistingKeyspace(action string) string {
if action == set {

if key_count < sizeNewKeyspace-1 {
key_count = key_count + 1
}
return fmt.Sprint(key_count)
}
randNum, err := rand.Int(rand.Reader, big.NewInt(key_count))
if err != nil {
log.Fatal("Error while generating random number for existing keyspace: ", err)
}
Expand Down
17 changes: 8 additions & 9 deletions go/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,30 +362,29 @@ pub unsafe extern "C" fn command(
let result: RedisResult<Option<CommandResponse>> = match value {
Value::Nil => Ok(None),
Value::SimpleString(text) => {
let vec = text.chars().map(|b| b as c_char).collect::<Vec<_>>();
let vec = text.into_bytes();
let (vec_ptr, len) = convert_vec_to_pointer(vec);
command_response.string_value = vec_ptr;
command_response.string_value = vec_ptr as *mut c_char;
command_response.string_value_len = len;
Ok(Some(command_response))
}
Value::BulkString(text) => {
let vec = text.iter().map(|b| *b as c_char).collect::<Vec<_>>();
let (vec_ptr, len) = convert_vec_to_pointer(vec);
command_response.string_value = vec_ptr;
let (vec_ptr, len) = convert_vec_to_pointer(text);
command_response.string_value = vec_ptr as *mut c_char;
command_response.string_value_len = len;
Ok(Some(command_response))
}
Value::VerbatimString { format: _, text } => {
let vec = text.chars().map(|b| b as c_char).collect::<Vec<_>>();
let vec = text.into_bytes();
let (vec_ptr, len) = convert_vec_to_pointer(vec);
command_response.string_value = vec_ptr;
command_response.string_value = vec_ptr as *mut c_char;
command_response.string_value_len = len;
Ok(Some(command_response))
}
Value::Okay => {
let vec = "OK".chars().map(|b| b as c_char).collect::<Vec<_>>();
let vec = String::from("OK").into_bytes();
let (vec_ptr, len) = convert_vec_to_pointer(vec);
command_response.string_value = vec_ptr;
command_response.string_value = vec_ptr as *mut c_char;
command_response.string_value_len = len;
Ok(Some(command_response))
}
Expand Down
3 changes: 2 additions & 1 deletion java/benchmarks/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
id "com.google.osdetector" version "1.7.3"
}

repositories {
Expand All @@ -12,7 +13,7 @@ dependencies {
def releaseVersion = System.getenv("GLIDE_RELEASE_VERSION");

if (releaseVersion) {
implementation "io.valkey:valkey-glide:" + releaseVersion
implementation "io.valkey:valkey-glide:" + releaseVersion + ":${osdetector.classifier}"
} else {
implementation project(':client')
}
Expand Down
31 changes: 31 additions & 0 deletions java/client/src/main/java/glide/api/GlideClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import static command_request.CommandRequestOuterClass.RequestType.Ping;
import static command_request.CommandRequestOuterClass.RequestType.RandomKey;
import static command_request.CommandRequestOuterClass.RequestType.Scan;
import static command_request.CommandRequestOuterClass.RequestType.ScriptExists;
import static command_request.CommandRequestOuterClass.RequestType.ScriptFlush;
import static command_request.CommandRequestOuterClass.RequestType.ScriptKill;
import static command_request.CommandRequestOuterClass.RequestType.Select;
import static command_request.CommandRequestOuterClass.RequestType.Time;
import static command_request.CommandRequestOuterClass.RequestType.UnWatch;
Expand Down Expand Up @@ -499,4 +502,32 @@ public CompletableFuture<Object[]> scan(
GlideString[] arguments = new ArgsBuilder().add(cursor).add(options.toArgs()).toArray();
return commandManager.submitNewCommand(Scan, arguments, this::handleArrayResponseBinary);
}

@Override
public CompletableFuture<Boolean[]> scriptExists(@NonNull String[] sha1s) {
return commandManager.submitNewCommand(
ScriptExists, sha1s, response -> castArray(handleArrayResponse(response), Boolean.class));
}

@Override
public CompletableFuture<Boolean[]> scriptExists(@NonNull GlideString[] sha1s) {
return commandManager.submitNewCommand(
ScriptExists, sha1s, response -> castArray(handleArrayResponse(response), Boolean.class));
}

@Override
public CompletableFuture<String> scriptFlush() {
return commandManager.submitNewCommand(ScriptFlush, new String[0], this::handleStringResponse);
}

@Override
public CompletableFuture<String> scriptFlush(@NonNull FlushMode flushMode) {
return commandManager.submitNewCommand(
ScriptFlush, new String[] {flushMode.toString()}, this::handleStringResponse);
}

@Override
public CompletableFuture<String> scriptKill() {
return commandManager.submitNewCommand(ScriptKill, new String[0], this::handleStringResponse);
}
}
Loading

0 comments on commit 4daa3f0

Please sign in to comment.