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

Fix value conversion for CONFIG GET. #2381

Open
wants to merge 1 commit into
base: release-1.2
Choose a base branch
from

Conversation

Yury-Fridlyand
Copy link
Collaborator

@Yury-Fridlyand Yury-Fridlyand commented Oct 2, 2024

Multi-node RESP2 value wasn't converted

Fixes #2392

Copy link
Collaborator

@jonathanl-bq jonathanl-bq left a comment

Choose a reason for hiding this comment

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

A few small suggestions, but seems good otherwise.

// Second parameter is a function which returns true if value needs to be converted
SingleOrMultiNode(
&'a Option<ExpectedReturnType<'a>>,
Option<fn(Value) -> bool>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure how difficult it would be to change, but generally you should prefer taking a generic implementing a closure trait like F: Fn(Value) -> bool if possible because plain function pointers can't capture their environment like closures can. We don't really need the extra flexibility for our existing cases, so this isn't critical to do. Might not be worth making this change if it involves an extra Box alloc, but maybe worth a try at least.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you mean something like this?

pub(crate) enum ExpectedReturnType<'a, F: Fn(Value) -> bool> {
    Map {
        key_type: &'a Option<ExpectedReturnType<'a, F>>,
        value_type: &'a Option<ExpectedReturnType<'a, F>>,
    },
    // Second parameter is a function which returns true if value needs to be converted
    SingleOrMultiNode(
        &'a Option<ExpectedReturnType<'a, F>>,
        Option<F>,
    ),
...

(I also need to update all references to ExpectedReturnType type)
Or

pub(crate) enum ExpectedReturnType<'a> {
    Map {
        key_type: &'a Option<ExpectedReturnType<'a>>,
        value_type: &'a Option<ExpectedReturnType<'a>>,
    },
    // Second parameter is a function which returns true if value needs to be converted
    SingleOrMultiNode(
        &'a Option<ExpectedReturnType<'a>>,
        Option<&'a dyn Fn(Value) -> bool>,
    ),
...

glide-core/src/client/value_conversion.rs Outdated Show resolved Hide resolved
@Yury-Fridlyand Yury-Fridlyand linked an issue Oct 4, 2024 that may be closed by this pull request
@Yury-Fridlyand Yury-Fridlyand force-pushed the core/yuryf-fix-config-get branch 3 times, most recently from e51ad3c to 507f5f9 Compare October 15, 2024 23:19
@Yury-Fridlyand Yury-Fridlyand changed the base branch from main to release-1.2 October 15, 2024 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CONFIG GET REPS2 multinode response isn't converted
2 participants