-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* switch to using event store * now handles if graographical area updated fails
- Loading branch information
1 parent
8e1777d
commit 426b5c1
Showing
12 changed files
with
101 additions
and
85 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
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,6 @@ | ||
namespace OpenFTTH.GDBIntegrator.Config; | ||
|
||
public sealed record EventStoreSetting | ||
{ | ||
public string ConnectionString { get; init; } | ||
} |
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
40 changes: 40 additions & 0 deletions
40
src/OpenFTTH.GDBIntegrator.Producer/EventStore/EventStoreProducer.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,40 @@ | ||
using OpenFTTH.EventSourcing; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace OpenFTTH.GDBIntegrator.Producer.EventStore | ||
{ | ||
public class EventStoreProducer : IProducer | ||
{ | ||
private readonly IEventStore _eventStore; | ||
|
||
public EventStoreProducer(IEventStore eventStore) | ||
{ | ||
_eventStore = eventStore; | ||
} | ||
|
||
public async Task Produce(Guid streamId, object toposMessage) | ||
{ | ||
var currentVersion = 0L; | ||
|
||
if (_eventStore.Aggregates.CheckIfAggregateIdHasBeenUsed(streamId)) | ||
{ | ||
// We retrieve the latest version each time, | ||
// so we don't have to keep internal version state up to date. | ||
currentVersion = await _eventStore | ||
.CurrentStreamVersionAsync(streamId) ?? | ||
throw new InvalidOperationException( | ||
"Could not get stream version. The method returned null."); | ||
} | ||
|
||
// Next expected version is current version plus one. | ||
var nextExpectedVersion = currentVersion + 1; | ||
|
||
await _eventStore | ||
.AppendStreamAsync( | ||
streamId, | ||
nextExpectedVersion, | ||
new[] { toposMessage }); | ||
} | ||
} | ||
} |
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 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
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