Skip to content

Add overload to deserialize GetBulkStateAsync item values#1173

Merged
halspang merged 11 commits into
dapr:masterfrom
WhitWaldo:bulk-state-deserialization
Feb 16, 2024
Merged

Add overload to deserialize GetBulkStateAsync item values#1173
halspang merged 11 commits into
dapr:masterfrom
WhitWaldo:bulk-state-deserialization

Conversation

@WhitWaldo
Copy link
Copy Markdown
Contributor

@WhitWaldo WhitWaldo commented Oct 23, 2023

Adds overload to BulkStateItem and GetBulkStateAsync to perform SDK-based deserialization of returned values instead of strictly returning serialized strings.

Signed-off-by: Whit Waldo whit.waldo@innovian.net

Description

Explained in more detail at #1172 , but GetBulkItemAsync returns a BulkStateItem with a Key, ETag and Value wherein each is typed as a string and the user is expected to deserialize the Value. Because the state might have been originally added one by one, relying on Dapr and its serialization options to serialize everything, this can cause downstream issues deserializing values not originally serialized by the developer.

As such, just as GetStateAsync allows a type parameter to deserialize each returned value, I've added the same overload to GetBulkItemAsync to deserialize using the same mechanism as GetStateAsync to deserialize each of the returned items as part of an overloaded and generically-typed BulkItemState.

Issue reference

As it's a simple addition, I didn't think it really merited a lot of discussion as the functionality is already available for single items (and this just adds the same for multiple items).

Please reference the issue this PR will close: #1172

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

I'll work on finding relevant documentation and updating that right now.

…ased deserialization of returned values instead of strictly returning serialized strings.

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
@WhitWaldo WhitWaldo requested review from a team as code owners October 23, 2023 09:37
Comment thread src/Dapr.Client/DaprClient.cs Outdated
Comment thread src/Dapr.Client/BulkStateItem.cs
Comment thread src/Dapr.Client/DaprClientGrpc.cs
…e other (typed or not)

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
…ialized nature of the value.

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
…h the non-generic and generic public methods can deserialize the data once as necessary.

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
philliphoff
philliphoff previously approved these changes Dec 5, 2023
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 6, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (034de3e) 67.28% compared to head (fada655) 67.36%.

Files Patch % Lines
src/Dapr.Client/BulkStateItem.cs 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1173      +/-   ##
==========================================
+ Coverage   67.28%   67.36%   +0.08%     
==========================================
  Files         174      174              
  Lines        6006     6028      +22     
  Branches      670      672       +2     
==========================================
+ Hits         4041     4061      +20     
- Misses       1798     1800       +2     
  Partials      167      167              
Flag Coverage Δ
net6 67.34% <92.30%> (+0.08%) ⬆️
net7 67.34% <92.30%> (+0.08%) ⬆️
net8 67.35% <92.30%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Contributor

@halspang halspang left a comment

Choose a reason for hiding this comment

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

Looks good overall, just some formatting nitpicks.

Comment thread src/Dapr.Client/DaprClientGrpc.cs Outdated
Comment thread src/Dapr.Client/DaprClientGrpc.cs
Comment thread src/Dapr.Client/DaprClientGrpc.cs Outdated
…ion requires each have their own line.

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
@hhunter-ms
Copy link
Copy Markdown
Contributor

@halspang @philliphoff is this ready for merge? just checking since there's a corresponding docs PR waiting in the wings for this :)

@philliphoff
Copy link
Copy Markdown
Collaborator

@hhunter-ms @halspang If Hal is ok with the last set to changes he requested (and the required merge is clean), I say merge it.

@philliphoff philliphoff modified the milestone: v1.13 Feb 15, 2024
@halspang halspang merged commit 83858d7 into dapr:master Feb 16, 2024
@WhitWaldo WhitWaldo deleted the bulk-state-deserialization branch February 17, 2024 06:12
divzi-p pushed a commit to divzi-p/dotnet-sdk that referenced this pull request Dec 10, 2024
* Adds overload to BulkStateItem and GetBulkStateAsync to perform SDK-based deserialization of returned values instead of strictly returning serialized strings.
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Updated method summary to better direct user towards one method or the other (typed or not)
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added comments to the typed BulkStateItem to better reflect the deserialized nature of the value.

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Refactored GetBulkStateAsync method to a shared private method so both the non-generic and generic public methods can deserialize the data once as necessary.

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Removed excessive space in comment.

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Formatting: If we're separating parameters to separate lines, convention requires each have their own line.

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

---------

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Co-authored-by: halspang <70976921+halspang@users.noreply.github.com>
Co-authored-by: Phillip Hoff <phillip@orst.edu>
Signed-off-by: Divya Perumal <diperuma@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GetBulkStateAsync should have typed overload that performs bulk deserialization

4 participants