Skip to content

refactor: move pub/sub out of DaprClientImpl - #1905

Merged
dapr-bot merged 1 commit into
dapr:masterfrom
javier-aliaga:refactor/split-daprclientimpl-pubsub
Nov 12, 2026
Merged

dapr-bot merged 1 commit into
dapr:masterfrom
javier-aliaga:refactor/split-daprclientimpl-pubsub

Conversation

@javier-aliaga

Copy link
Copy Markdown
Contributor

Description

Fourth step of splitting DaprClientImpl into package-private classes, one per building block. This PR moves pub/sub.

  • New package-private class DaprPubSubClient holds publishEvent, publishEvents (with the bulkPublishEventAlpha1 fallback), the subscribeToEvents and subscribeToTopic overloads, and buildSubscription. The bodies are unchanged.
  • The two subscription paths built their stub with grpcInterceptors.intercept(asyncStub). They now call a new DaprGrpcCalls.intercept(), which makes the same call on the same stub and interceptors.
  • DaprClientImpl no longer reads its asyncStub field, so the field is removed. DaprGrpcCalls still holds the stub.
  • The subscription logger keeps the DaprClientImpl category, so existing log configuration still applies.
  • The public methods on DaprClientImpl keep their signatures and Javadoc, and delegate in one line.
  • No public API change. DaprClientImpl goes from 2,065 to 1,829 lines.

Issue reference

Part of #1875

Checklist

  • Code compiles correctly
  • Created/updated tests. DaprClientGrpcTest, DaprPreviewClientGrpcTest and SubscriptionTest cover pub/sub through the public methods. The 626 sdk unit tests pass unchanged.
  • Extended the documentation. Not needed, internal change.

Move publishEvent, publishEvents and the subscribeToEvents/subscribeToTopic
overloads into a package-private DaprPubSubClient. The public methods on
DaprClientImpl now delegate to it. Add DaprGrpcCalls.intercept() for the
subscription paths, which run without a Reactor context, and drop the
asyncStub field that DaprClientImpl no longer reads.

Part of dapr#1875

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

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 present, and the refactoring preserves the existing public pub/sub API while separating its implementation into a dedicated client.

No open issues 🎉

What changed in this PR

This PR refactors pub/sub operations out of DaprClientImpl into a package-private DaprPubSubClient, preserving the existing public API and behavior while reducing the main client's responsibilities.

Changes:

  • Moved publishing and subscription implementations into DaprPubSubClient.
  • Added shared async gRPC stub interception through DaprGrpcCalls.
  • Updated DaprClientImpl to delegate pub/sub methods and removed its direct async stub dependency.
File Description
sdk/​src/​main/​java/​io/​dapr/​client/​DaprPubSubClient.java Adds the package-private implementation for pub/sub publishing, subscriptions, and subscription handling.
sdk/​src/​main/​java/​io/​dapr/​client/​DaprGrpcCalls.java Adds shared interception of the async gRPC stub for calls without a Reactor context.
sdk/​src/​main/​java/​io/​dapr/​client/​DaprClientImpl.java Initializes the pub/sub client and delegates the existing public pub/sub methods.

Review effort: Lite

@javier-aliaga
javier-aliaga marked this pull request as ready for review November 12, 2026 12:21
@javier-aliaga
javier-aliaga requested review from a team as code owners November 12, 2026 12:21

@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 85.09317% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.00%. Comparing base (c5969a0) to head (12e64d5).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...src/main/java/io/dapr/client/DaprPubSubClient.java 83.89% 12 Missing and 12 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1905      +/-   ##
============================================
+ Coverage     81.93%   82.00%   +0.06%     
- Complexity     3651     3664      +13     
============================================
  Files           330      331       +1     
  Lines         11351    11367      +16     
  Branches       1290     1290              
============================================
+ Hits           9301     9322      +21     
+ Misses         1556     1550       -6     
- Partials        494      495       +1     

☔ 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 9d51882 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