feat: EF-core-oubox-support-for-Dapr - #1863
Conversation
|
Hi @WhitWaldo can you review this ? |
|
First of all, thank you for putting this together especially in response to a long-standing ask from the community. I don't mind reviewing and likely approving the extensions to simplify setting up the state transaction requests from the But with regards to the That said, I can certainly imagine a scenario where it might be a useful feature. I would instead urge you to consider publishing the package to NuGet yourself. Reach out to @marcduiker on Discord and schedule some time to show off your work and promote it to the larger Dapr community - I'm sure there's someone that can use that. With regards to this PR though, I regret that I cannot accept it as provided. If you can instead remove everything but the |
Adds convenience APIs on Dapr.Client that make it easier to compose state transactions that engage the Dapr runtime's native transactional outbox feature via a state store component (outboxPublishPubsub metadata). - DaprOutboxMetadata: canonical metadata key constants (outbox.projection, outbox.pubsubname, outbox.topic, cloudevent.* overrides). - StateTransactionRequestExtensions: WithOutboxProjection(...) and WithCloudEventMetadata(...) fluent helpers. - OutboxTransactionBuilder: composer that enforces the state entry and its outbox projection share the same key, so a single ExecuteStateTransactionAsync call publishes the message atomically with the state write. Tests: 22 new unit tests in Dapr.Client.Test covering metadata keys, extension defaults, and the key-match invariant. Full Dapr.Client.Test suite is green (283 tests). Refs dapr#1494 Signed-off-by: Psingle20 <ingleprachit91@gmail.com>
50786f3 to
2bf105e
Compare
Thanks for the thoughtful review and for drawing a clear line on where the SDK ends and userland begins. That reasoning makes sense: the runtime already owns the transactional outbox as a first-class capability via the state store components, and the EF Core package I put together is really an alternative for users whose aggregates live outside a Dapr state store, rather than an extension of the runtime feature. Different pattern, different home. I've force-pushed the branch back to just the [Dapr.Client] and made the required changes. I'll spin the EF Core work out to its own repo + NuGet and reach out to @marcduiker on Discord to see about promoting it through the community channel. Appreciate the pointer. |
|
Hey @Psingle20! Yeah, this is a great topic for a community call. my Discord handle is |
Hi @marcduiker, sorry for the late reply. I’ve been caught up with work and haven’t been keeping well. I’ll try to reach out around the weekend. |
|
Hi @marcduiker have sent you a friend request my discord handle is Prachpit . Let me know how i can get involved with community! |
There was a problem hiding this comment.
Pull request overview
This PR adds first-class helper APIs in Dapr.Client to make it easier and safer to compose state transactions that leverage Dapr’s native transactional outbox behavior via state-store metadata, along with unit tests validating the new helpers.
Changes:
- Introduces
DaprOutboxMetadataconstants for well-known outbox / CloudEvent metadata keys. - Adds
StateTransactionRequestExtensionsto mark requests as outbox projections and to apply CloudEvent metadata overrides without mutating the source request. - Adds
OutboxTransactionBuilderto compose ordered state/projection request pairs forExecuteStateTransactionAsync, plus unit tests for all new APIs.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Dapr.Client/DaprOutboxMetadata.cs | Adds public constants for outbox-related metadata keys. |
| src/Dapr.Client/StateTransactionRequestExtensions.cs | Adds non-mutating helpers to merge projection + CloudEvent metadata into StateTransactionRequest. |
| src/Dapr.Client/OutboxTransactionBuilder.cs | Adds a fluent builder that emits correctly ordered state + projection transaction requests. |
| test/Dapr.Client.Test/DaprOutboxMetadataTests.cs | Adds tests that lock metadata constant values to the runtime wire contract. |
| test/Dapr.Client.Test/StateTransactionRequestExtensionsTests.cs | Adds tests covering non-mutation, metadata merge behavior, and null-guarding. |
| test/Dapr.Client.Test/OutboxTransactionBuilderTests.cs | Adds tests for builder ordering, pairing behavior, and argument validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi @WhitWaldo I think this is good to go let me know if anything else required |
97b78b2 to
104a72d
Compare
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Prachit <112982404+Psingle20@users.noreply.github.com>
104a72d to
e4c6ae9
Compare
WhitWaldo
left a comment
There was a problem hiding this comment.
Looks good - thank you for taking the time to build and contribute this!
Description
Adds convenience APIs on
Dapr.Clientthat make it easier to compose state transactions engaging the Dapr runtime's native transactional outbox feature (state store component configured withoutboxPublishPubsuband related metadata).Scope-trimmed from the original submission per reviewer feedback — the
Dapr.EntityFrameworkCore.Outboxpackage I initially included will be published as a standalone community NuGet instead, since it's a userland alternative to the runtime outbox rather than an extension of it.Changes
DaprOutboxMetadata— canonical metadata key constants used by the state store outbox (outbox.projection,outbox.pubsubname,outbox.topic,cloudevent.id,cloudevent.type,cloudevent.source,cloudevent.datacontenttype,cloudevent.subject, etc.). Callers reference constants instead of stringly-typed keys.StateTransactionRequestExtensions— fluent helpers onStateTransactionRequest:WithOutboxProjection(pubsubName, topic, payload?, contentType?)— attaches the outbox projection metadata to a state entry.WithCloudEventMetadata(...)— setscloudevent.*overrides on an entry.OutboxTransactionBuilder— small composer that enforces the invariant that the state entry and its outbox projection share the same key, so a singleExecuteStateTransactionAsynccall publishes the message atomically with the state write.Testing
DaprOutboxMetadataTests— validates the key constants match Dapr's runtime contract.StateTransactionRequestExtensionsTests— covers default content type, metadata merging, and null-argument guards.OutboxTransactionBuilderTests— enforces the state-entry / projection key-match invariant, verifies the produced request shape, and rejects mismatched configurations.Dapr.Client.Testsuite is green: 283 / 283 passing on net10.0.Issue reference
Refs #1494
Checklist