Skip to content

Commit

Permalink
OutboxDispatcher moved from ctor to Init method of UnitOfWork
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstantinRyazantsev committed Aug 12, 2020
1 parent 0b03c4c commit e0efc1a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/Swisschain.Extensions.Idempotency/IUnitOfWork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ public interface IUnitOfWork : IAsyncDisposable
bool IsRolledBack { get; }
Outbox Outbox { get; }

Task Init(IOutboxWriteRepository outboxWriteRepository, Outbox outbox);
Task Init(IOutboxDispatcher defaultOutboxDispatcher,
IOutboxWriteRepository outboxWriteRepository,
Outbox outbox);

/// <summary>
/// Closes the <see cref="Outbox"/> and commits unit of work transaction
Expand Down
12 changes: 5 additions & 7 deletions src/Swisschain.Extensions.Idempotency/UnitOfWorkBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ namespace Swisschain.Extensions.Idempotency
{
public abstract class UnitOfWorkBase : IUnitOfWork
{
private readonly IOutboxDispatcher _defaultOutboxDispatcher;

public UnitOfWorkBase(IOutboxDispatcher defaultOutboxDispatcher)
{
_defaultOutboxDispatcher = defaultOutboxDispatcher;
}
private IOutboxDispatcher _defaultOutboxDispatcher;

public IOutboxWriteRepository OutboxWriteRepository { get; private set; }
public bool IsCommitted { get; private set; }
Expand All @@ -21,9 +16,12 @@ public UnitOfWorkBase(IOutboxDispatcher defaultOutboxDispatcher)
protected abstract Task RollbackImpl();
protected abstract ValueTask DisposeAsync(bool disposing);

public Task Init(IOutboxWriteRepository outboxWriteRepository,
public Task Init(IOutboxDispatcher defaultOutboxDispatcher,
IOutboxWriteRepository outboxWriteRepository,
Outbox outbox)
{
_defaultOutboxDispatcher = defaultOutboxDispatcher;

OutboxWriteRepository = outboxWriteRepository;
Outbox = outbox;

Expand Down
5 changes: 0 additions & 5 deletions tests/Tests/ExampleUnitOfWork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ namespace Tests
{
public class ExampleUnitOfWork : UnitOfWorkBase
{
public ExampleUnitOfWork(IOutboxDispatcher defaultOutboxDispatcher) :
base(defaultOutboxDispatcher)
{
}

protected override Task CommitImpl()
{
throw new System.NotImplementedException();
Expand Down

0 comments on commit e0efc1a

Please sign in to comment.