Skip to content
New issue

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

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

Already on GitHub? # to your account

Feature: Enable query state API #116

Merged
merged 12 commits into from
Apr 9, 2024
Merged

Feature: Enable query state API #116

merged 12 commits into from
Apr 9, 2024

Conversation

ruokun-niu
Copy link
Contributor

The query state API is an existing API that is currently in the Alpha stage. Currently, this capability is available in some other SDKs, e.g. the JavaScript SDK. In the Rust SDK, we cannot utilize the query API to fetch specific states in the Client Struct.

This PR utilizes the existing proto messages QueryStateRequest and QueryStateResponse to enable state querying. I have added a new function called query_state_alpha1() that takes in two parameters: store_name and query and an optional parameter: metadata.

The query can be defined using serde_json::json

Example:

let mut client = dapr::Client::<dapr::client::TonicClient>::connect(addr).await?;


let query_condition = json!({
    "filter": {
        "EQ": { "state": "CA" }
    },
    "sort": [
        {
            "key": "person.id",
            "order": "DESC"
        }
    ]
});

let response_result = match client.query_state_alpha1("statestore", query_condition, None).await {
    Ok(response) => response.results,
    Err(e) => {
        println!("Error: {:?}", e);
        return Ok(());
    }
};

Issue #115

Signed-off-by: Ruokun Niu <ruokunniu@microsoft.com>
Signed-off-by: Ruokun Niu <ruokunniu@microsoft.com>
Signed-off-by: Ruokun Niu <ruokunniu@microsoft.com>
Signed-off-by: Ruokun Niu <ruokunniu@microsoft.com>
Signed-off-by: Ruokun Niu <ruokunniu@microsoft.com>
Signed-off-by: Ruokun Niu <ruokunniu@microsoft.com>
@mikeee
Copy link
Member

mikeee commented Feb 13, 2024

Looks good, I have two questions:

  1. Does this work with redis-stack? If simple enough, this could be a good way to stand up a test env (as an alternative to mongodb)
  2. Could/should the two queries be combined into one app?

@mikeee mikeee added this to the 1.14 milestone Mar 14, 2024
Signed-off-by: Mike Nguyen <hey@mike.ee>
@ruokun-niu ruokun-niu requested review from a team as code owners April 8, 2024 10:00
@ruokun-niu
Copy link
Contributor Author

Hi @mikeee, thanks for the comments and sorry for my late response. I'll take a look into this and update the PR

@mikeee
Copy link
Member

mikeee commented Apr 8, 2024

No worries, I can update and get this pushed through if you'd prefer 👍

@ruokun-niu
Copy link
Contributor Author

That would be great! Thanks :)

mikeee added 5 commits April 9, 2024 19:54
Signed-off-by: mikeee <hey@mike.ee>
Signed-off-by: mikeee <hey@mike.ee>
Signed-off-by: mikeee <hey@mike.ee>
Signed-off-by: mikeee <hey@mike.ee>
Copy link
Member

@mikeee mikeee left a comment

Choose a reason for hiding this comment

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

lgtm

@mikeee mikeee merged commit 7dced71 into dapr:main Apr 9, 2024
15 checks passed
@mikeee
Copy link
Member

mikeee commented Apr 9, 2024

Thanks for the contribution @ruokun-niu, much appreciated 😄

@ruokun-niu
Copy link
Contributor Author

Thanks for the review and help!

@marcduiker
Copy link
Contributor

@holopin-bot @ruokun-niu Thank you!

Copy link

holopin-bot bot commented May 7, 2024

Congratulations @ruokun-niu, you just earned a badge! Here it is: https://holopin.io/claim/clvwgjwuk38440fme3ecbo1pv

This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account.
Or if you're new to Holopin, you can simply # with GitHub, which will do the trick!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: Querying state store add support for statestore query API
3 participants