-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename UnitOfWorkPipelineBehaviorConcurrentCounter to ConcurrentComma…
…ndCounter, delay telemetry events until all commands are processed
- Loading branch information
Showing
6 changed files
with
43 additions
and
37 deletions.
There are no files selected for viewing
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
29 changes: 29 additions & 0 deletions
29
application/shared-kernel/ApplicationCore/Behaviors/ConcurrentCommandCounter.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,29 @@ | ||
namespace PlatformPlatform.SharedKernel.ApplicationCore.Behaviors; | ||
|
||
/// <summary> | ||
/// The ConcurrentCommandCounter class is a concurrent counter used to count the number of concurrent commands that | ||
/// are being handled. It is used by only commit changes to the database when all commands have been handled. | ||
/// This is to ensure that all changes to all aggregates and entities are committed to the database only after all | ||
/// command and domain events are successfully handled. | ||
/// Additionally, this also ensures that Telemetry is only sent to Application Insights after all commands and | ||
/// domain events are successfully handled. | ||
/// </summary> | ||
public sealed class ConcurrentCommandCounter | ||
{ | ||
private int _concurrentCount; | ||
|
||
public void Increment() | ||
{ | ||
Interlocked.Increment(ref _concurrentCount); | ||
} | ||
|
||
public void Decrement() | ||
{ | ||
Interlocked.Decrement(ref _concurrentCount); | ||
} | ||
|
||
public bool IsZero() | ||
{ | ||
return _concurrentCount == 0; | ||
} | ||
} |
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
27 changes: 0 additions & 27 deletions
27
...on/shared-kernel/ApplicationCore/Behaviors/UnitOfWorkPipelineBehaviorConcurrentCounter.cs
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