Created
February 15, 2018 02:16
-
-
Save dcomartin/3f7f3257bead2a1a0cf2156ea9fa99ad to your computer and use it in GitHub Desktop.
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
public BankAccountGrain() | |
{ | |
var settings = ConnectionSettings | |
.Create() | |
.EnableVerboseLogging() | |
.UseConsoleLogger(); | |
_conn = EventStoreConnection.Create(settings, new IPEndPoint(IPAddress.Loopback, Defaultport)); | |
} | |
public override async Task OnActivateAsync() | |
{ | |
_stream = $"{GetType().Name}-{this.GetPrimaryKey()}"; | |
await _conn.ConnectAsync(); | |
StreamEventsSlice currentSlice; | |
var nextSliceStart = StreamPosition.Start; | |
do | |
{ | |
currentSlice = await _conn.ReadStreamEventsForwardAsync(_stream, nextSliceStart, 200, false); | |
foreach (var evnt in currentSlice.Events) | |
{ | |
base.RaiseEvent(DeserializeEvent(evnt.Event)); | |
} | |
nextSliceStart = (int)currentSlice.NextEventNumber; | |
} while (!currentSlice.IsEndOfStream); | |
await ConfirmEvents(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment