-
Notifications
You must be signed in to change notification settings - Fork 335
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
Proposal: Add TryGetStateAsync method for non-actor state management operations #1178
Comments
While I'm personally not fond of Since I do wonder if/how that might impact the bulk get state operations (e.g. in light of #1173). Do they also need a means of indicating that the state was not found? (Off the top of my head, I don't recall whether bulk get state operations omit entries for keys that do not exist, and the API docs don't explicitly state one way or the other.) |
This whole proposal evolved from reading through the SDK code to answer the question "What happens if the key doesn't exist in the state?". The docs don't mention it, but after completing this work, I'd be happy to clarify this either way in the docs as well. I wasn't a huge fan of Another method that could be addressed here: With regards to #1173 , I'm going to have to dig through what's happening in the sidecar as I just look at look at the .NET SDK and it's just enumerating the returned items, so any exclusions for missing keys happen external to the SDK. That said, I'd be happy to take a stab at making changes there as well (if necessary) to better support a |
/assign |
Describe the proposal
When accessing a state store from a non-actor, there exists a
GetStateAsync<T>
method. Unfortunately, if the key doesn't exist, this returns adefault(T)
, which, depending on the type of T doesn't necessarily tell you much about whether the state actually exists or not.When accessing state from an Actor, there exists, a
TryGetStateAsync<T>
which addresses this very problem since it returns aConditionalValue<T>
, indicating whether the key exists or not.I would like to propose that
TryGetStateAsync<T>
be added to the non-actor state store API. It should return aConditionalValue<T>
like that of the actor API. Most importantly, it fills a gap in the API right now in that there appears to be no definite way to confirm that a given key otherwise exists or not.I'd be happy to contribute a PR, if this is an acceptable addition.
Proposed breaking change
Today,
ConditionalValue
exists only in Dapr.Actors. To avoid having two identical types, this should be refactored out to a more common project likeDapr.Client
.Should be it - this looks to just be an issue in how the .NET API works and I don't see that it requires any changes to the sidecar itself.
The text was updated successfully, but these errors were encountered: