-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dcef08e
commit 0e71e79
Showing
21 changed files
with
307 additions
and
162 deletions.
There are no files selected for viewing
13 changes: 0 additions & 13 deletions
13
src/Swisschain.Extensions.Idempotency/DefaultIdGeneratorRepository.cs
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
src/Swisschain.Extensions.Idempotency/DefaultOutboxReadRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Swisschain.Extensions.Idempotency | ||
{ | ||
internal sealed class DefaultOutboxReadRepository : IOutboxReadRepository | ||
{ | ||
public Task<Outbox> GetOrDefault(string idempotencyId) | ||
{ | ||
throw new InvalidOperationException("Outbox repository is not configured. To use outbox, you need to configure a persistence in service.AddIdempotency(c => {...})"); | ||
} | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
src/Swisschain.Extensions.Idempotency/DefaultOutboxRepository.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/Swisschain.Extensions.Idempotency/IOutboxReadRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Swisschain.Extensions.Idempotency | ||
{ | ||
/// <summary> | ||
/// Should work out of the context of the <see cref="IUnitOfWork"/> transaction | ||
/// </summary> | ||
public interface IOutboxReadRepository | ||
{ | ||
Task<Outbox> GetOrDefault(string idempotencyId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,48 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Swisschain.Extensions.Idempotency | ||
{ | ||
public interface IUnitOfWork : IDisposable | ||
public interface IUnitOfWork : IAsyncDisposable | ||
{ | ||
IIdGeneratorRepository IdGeneratorRepository { get; } | ||
IOutboxWriteRepository OutboxWriteRepository { get; } | ||
string IdempotencyId { get; } | ||
bool IsCommitted { get; } | ||
bool IsRolledBack { get; } | ||
Outbox Outbox { get; } | ||
|
||
/// <summary> | ||
/// Should be used only by Swisschain.Extensions.Idempotency | ||
/// Closes the <see cref="Outbox"/> and commits unit of work transaction | ||
/// </summary> | ||
IOutboxRepository Outbox { get; } | ||
Task Commit(); | ||
|
||
/// <summary> | ||
/// Should be used only by Swisschain.Extensions.Idempotency | ||
/// Rollbacks unit of work transaction | ||
/// </summary> | ||
void Commit(); | ||
Task Rollback(); | ||
|
||
/// <summary> | ||
/// Should be used only by Swisschain.Extensions.Idempotency | ||
/// Generates or returns existing unique ID for the given <see cref="IdempotencyId"/> using | ||
/// <see cref="IdGeneratorRepository"/> and specified <paramref name="generatorName"/> | ||
/// </summary> | ||
void Rollback(); | ||
Task<long> GenerateId(string generatorName); | ||
|
||
/// <summary> | ||
/// Generates or returns existing unique ID for the specified <paramref name="idempotencyId"/> using | ||
/// <see cref="IdGeneratorRepository"/> and specified <paramref name="generatorName"/> | ||
/// </summary> | ||
Task<long> GenerateId(string idempotencyId, string generatorName); | ||
|
||
/// <summary> | ||
/// Dispatches <see cref="Outbox"/> using default <see cref="IOutboxDispatcher"/>. | ||
/// It's recommended to use more specific dispatcher if possible. | ||
/// </summary> | ||
Task EnsureOutboxDispatched(); | ||
|
||
/// <summary> | ||
/// Dispatches <see cref="Outbox"/> using specified <paramref name="dispatcher"/>. | ||
/// </summary> | ||
Task EnsureOutboxDispatched(IOutboxDispatcher dispatcher); | ||
} | ||
} | ||
} |
11 changes: 7 additions & 4 deletions
11
src/Swisschain.Extensions.Idempotency/IUnitOfWorkFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
namespace Swisschain.Extensions.Idempotency | ||
using System.Threading.Tasks; | ||
|
||
namespace Swisschain.Extensions.Idempotency | ||
{ | ||
public interface IUnitOfWorkFactory | ||
public interface IUnitOfWorkFactory<TUnitOfWork> | ||
where TUnitOfWork : UnitOfWorkBase | ||
{ | ||
IUnitOfWork Create(); | ||
Task<TUnitOfWork> Create(Outbox outbox); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Swisschain.Extensions.Idempotency/IUnitOfWorkManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Swisschain.Extensions.Idempotency | ||
{ | ||
public interface IUnitOfWorkManager<TUnitOfWork> | ||
where TUnitOfWork : UnitOfWorkBase | ||
{ | ||
Task<TUnitOfWork> Begin(string idempotencyId); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.