Skip to content

refactor: move state management out of DaprClientImpl - #1902

Merged
dapr-bot merged 2 commits into
dapr:masterfrom
javier-aliaga:refactor/split-daprclientimpl-state
Nov 12, 2026
Merged

dapr-bot merged 2 commits into
dapr:masterfrom
javier-aliaga:refactor/split-daprclientimpl-state

Conversation

@javier-aliaga

Copy link
Copy Markdown
Contributor

Description

Third step of splitting DaprClientImpl into package-private classes, one per building block. This PR moves state management.

  • New package-private class DaprStateClient holds getState, getBulkState, saveBulkState, deleteState, executeStateTransaction, queryState and their proto mapping. The bodies are unchanged.
  • One line inside the moved code changes. queryState used JSON_REQUEST_MAPPER inherited from AbstractDaprClient, and now names it AbstractDaprClient.JSON_REQUEST_MAPPER. It is the same static field.
  • The public methods on DaprClientImpl keep their signatures and Javadoc, and delegate in one line.
  • No public API change. DaprClientImpl goes from 2,299 to 1,953 lines.

Issue reference

Part of #1875

Checklist

  • Code compiles correctly
  • Created/updated tests. DaprClientGrpcTest covers state through the public methods. The 593 sdk unit tests pass unchanged.
  • Extended the documentation. Not needed, internal change.

Move getState, getBulkState, saveBulkState, deleteState,
executeStateTransaction, queryState and their proto mapping into a
package-private DaprStateClient class. The public methods on
DaprClientImpl keep their signatures and delegate to it.
No public API change.

Part of dapr#1875

Signed-off-by: Javier Aliaga <javier@diagrid.io>
Copilot AI lite review requested due to automatic review settings November 9, 2026 10:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are identified for this focused extraction of state-management responsibilities.

No open issues 🎉

What changed in this PR

This PR extracts state-management functionality from DaprClientImpl into a package-private DaprStateClient, preserving the public API and behavior while reducing the implementation class size.

Changes:

  • Added DaprStateClient for state retrieval, persistence, deletion, transactions, queries, and protobuf mappings.
  • Updated DaprClientImpl to initialize the state client and delegate the existing public state APIs.
  • Qualified the shared JSON_REQUEST_MAPPER reference in queryState.
File Description
sdk/​src/​main/​java/​io/​dapr/​client/​DaprStateClient.java Contains the extracted state-management operations, request construction, gRPC calls, serialization, and response mapping.
sdk/​src/​main/​java/​io/​dapr/​client/​DaprClientImpl.java Initializes DaprStateClient and delegates the existing public state methods.

Review effort: Lite

@javier-aliaga
javier-aliaga marked this pull request as ready for review November 9, 2026 10:57
@javier-aliaga
javier-aliaga requested review from a team as code owners November 9, 2026 10:57
artur-ciocanu
artur-ciocanu previously approved these changes Nov 11, 2026

@artur-ciocanu artur-ciocanu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Love it!

@artur-ciocanu

Copy link
Copy Markdown
Contributor

@javier-aliaga looks great, please fix the conflicts and we are good to go.

Signed-off-by: artur-ciocanu <artur.ciocanu@gmail.com>
Copilot AI lite review requested due to automatic review settings November 12, 2026 02:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported, and the refactoring preserves the public API and existing state-operation behavior while separating state management into a dedicated client.

No open issues 🎉

Review effort: Lite

@artur-ciocanu
artur-ciocanu self-requested a review November 12, 2026 03:47

@artur-ciocanu artur-ciocanu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Love it.

@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.43478% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.93%. Comparing base (e2e5b3c) to head (409543c).

Files with missing lines Patch % Lines
.../src/main/java/io/dapr/client/DaprStateClient.java 90.13% 10 Missing and 12 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1902      +/-   ##
============================================
+ Coverage     81.92%   81.93%   +0.01%     
- Complexity     3644     3651       +7     
============================================
  Files           329      330       +1     
  Lines         11340    11351      +11     
  Branches       1290     1290              
============================================
+ Hits           9290     9301      +11     
  Misses         1556     1556              
  Partials        494      494              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dapr-bot
dapr-bot merged commit c5969a0 into dapr:master Nov 12, 2026
17 checks passed
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.

4 participants