BrighterCommand / BrighterCommand/Brighter

[Feature] UseOutboxArchiver should not require DbTransaction generic type

Open
#3,878 1 comment 0 reactions 0 assignees View on GitHub
.NET 0 - Backlog feature request help wanted V10.X
Dominant language
C#
Stars
2.5k
Forks
296
Avg merge
1d 11h
Merged PRs (30d)
21

Description

**Is your feature request related to a problem? Please describe.**
While migrating to V10 i stumbled opon this issue:
```csharp
// Proper UseOutboxArchiver invocation looks like this:
brighterBuilder.UseOutboxArchiver(new NullOutboxArchiveProvider(), options => options.MinimumAge = TimeSpan.FromDays(4));
// But that would require knowing the transaction type at compile time. And we don't, since there will be different transaction types for mongo and relational dbs.
```

Since we support using Postgres or MongoDB as a outbox provider - we cannot set the DbTransaction generic type during setting up the outbox archiver. I've found this workaround to work:

```csharp
typeof(HostedServiceCollectionExtensions)
.GetMethod(nameof(HostedServiceCollectionExtensions.UseOutboxArchiver))!
.MakeGenericMethod(transactionType)
.Invoke(null, [
brighterBuilder,
new NullOutboxArchiveProvider(),
new Action(opt => opt.MinimumAge = TimeSpan.FromDays(4))
]);
```
The `transactionType` is passed down from microservice configuration and can be either mongo or postgres implementation. I think you are using similar logic when registering the outbox in `AddProducers`:
https://github.com/BrighterCommand/Brighter/blob/fc3933f36b1f071bdb039e5b0f7856f430da3c75/src/Paramore.Brighter.Extensions.DependencyInjection/ServiceCollectionExtensions.cs#L166-L178

I think the same (or similar) logic can be performed in the `UseOutboxArchiver` helper (although i didn't analyze this to know for sure).

**Describe the solution you'd like**
Ideally, `UseOutboxArchiver` should infer the transactionType automatically (i think it was the case in v9)

Contributor guide

Open the contributing guide

Research direction

Start in src/Paramore.Brighter.Extensions.DependencyInjection/ServiceCollectionExtensions.cs, especially AddProducers and the UseOutboxArchiver helper. Compare how transaction types are selected for PostgreSQL and MongoDB, then determine the existing tests or registration path that should verify the helper can be called without a transaction-type generic argument. Done means callers no longer need to know the transaction type when configuring the outbox archiver.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, mongodb, postgresql
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.