Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go: Implement PfMerge command #3082

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

niharikabhavaraju
Copy link
Collaborator

Go: Implement PfMerge command

Signed-off-by: Niharika Bhavaraju <[email protected]>
@niharikabhavaraju niharikabhavaraju requested a review from a team as a code owner February 5, 2025 09:59
@niharikabhavaraju niharikabhavaraju self-assigned this Feb 5, 2025
//
// [valkey.io]: https://valkey.io/commands/pfmerge/
func (client *baseClient) PfMerge(destination string, sourceKeys []string) (string, error) {
result, err := client.executeCommand(C.PfMerge, append([]string{destination}, sourceKeys...))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check if at-least one sourceKey is as PFMerge require at least one source key and this would lead to anyhow failure and will waste one network call, we can use something like this :-

if len(sourceKeys) == 0 {
    return "", errors.New("at least one source key is required for PfMerge")
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need, we don't do this in other commands/clients

Copy link
Collaborator

@omangesg omangesg Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But adding this check will make the execution of command more efficient isn't it, and if other clients have not implemented such behavior, it seems a miss because anyhow the execution of command is going to fail.

@Yury-Fridlyand Yury-Fridlyand added the go golang wrapper label Feb 5, 2025
Comment on lines 3615 to 3622
// Note:
//
// In cluster mode, if keys in `keyValueMap` map to different hash slots, the command
// will be split across these slots and executed separately for each. This means the command
// is atomic only at the slot level. If one or more slot-specific requests fail, the entire
// call will return the first encountered error, even though some requests may have succeeded
// while others did not. If this behavior impacts your application logic, consider splitting
// the request into sub-requests per slot to ensure atomicity.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be another cross-slot notice. If keys mapped to different slots, command fails.

Copy link
Collaborator

@Yury-Fridlyand Yury-Fridlyand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update command example to match new example template (see developer doc and/or other commands)
Add a changelog entry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go golang wrapper
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants