-
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.
ID Generator moved out of the unit of work
- Loading branch information
1 parent
e6dcf4a
commit 51f2ff2
Showing
7 changed files
with
44 additions
and
26 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/Swisschain.Extensions.Idempotency/DefaultIdGeneratorRepository.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 DefaultIdGeneratorRepository : IIdGeneratorRepository | ||
{ | ||
public Task<long> GetId(string idempotencyId, string generatorName) | ||
{ | ||
throw new InvalidOperationException("ID generator repository is not configured. To use ID generator, you need to configure a persistence in service.AddIdempotency(c => {...})"); | ||
} | ||
} | ||
} |
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,9 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Swisschain.Extensions.Idempotency | ||
{ | ||
public interface IIdGenerator | ||
{ | ||
Task<long> GetId(string idempotencyId, string generatorName); | ||
} | ||
} |
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
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,19 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Swisschain.Extensions.Idempotency | ||
{ | ||
internal sealed class IdGenerator : IIdGenerator | ||
{ | ||
readonly IIdGeneratorRepository _idGeneratorRepository; | ||
|
||
public IdGenerator(IIdGeneratorRepository idGeneratorRepository) | ||
{ | ||
_idGeneratorRepository = idGeneratorRepository; | ||
} | ||
|
||
public Task<long> GetId(string idempotencyId, string generatorName) | ||
{ | ||
return _idGeneratorRepository.GetId(idempotencyId, generatorName); | ||
} | ||
} | ||
} |
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