private async Task <IStream> CreateStream(string streamId) { var stream = _streams.Open(streamId); for (int value = 1; value <= 10; value++) { await stream.AppendAsync(new ValueCollected(value)); } return(stream); }
protected async Task GenerateEmptyUntil(Int64 positionTo) { IChunk chunk; do { var stream = _streamsFactory.Open("Empty"); chunk = await stream.AppendAsync(null).ConfigureAwait(false); lastUsedPosition = chunk.Position; } while (chunk.Position < positionTo); }
public async Task should_return_snapshotted_value_on_empty_stream() { await _snapshots.AddAsync("sequence_1/Sum", new SnapshotInfo( "sequence_1", 11, new Sum { Total = 1 }, "1" )).ConfigureAwait(false); var sequence = _streams.Open("sequence_1"); var result = await sequence .Aggregate() .WithCache(_snapshots) .RunAsync <Sum>().ConfigureAwait(false); Assert.Equal(1, result.Total); }
public Task <T> ProcessAsync <T>(String streamId, int versionUpTo) where T : class, new() { var stream = _streams.Open(streamId); return(stream .Aggregate() .ToIndex(versionUpTo) .RunAsync <T>(StreamProcessorManagerPayloadProcessor.Instance, CancellationToken.None)); }
protected Changeset ProcessEvent(DomainEvent evt, bool inSameCommitAsPrevious) { Int64 commitId = inSameCommitAsPrevious ? _lastCommit : ++_lastCommit; evt.SetPropertyValue(d => d.AggregateId, new SampleAggregateId(_aggregateIdSeed)); evt.SetPropertyValue(d => d.CheckpointToken, commitId); Changeset cs = new Changeset(_aggregateVersion++, new Object[] { evt }); var streamFactory = new StreamsFactory(_persistence); var stream = streamFactory.Open(evt.AggregateId); stream.AppendAsync(cs).Wait(); return(cs); }
private static async Task streams_api() { var persister = CreateYourStore(); var streams = new StreamsFactory(persister); Console.WriteLine("Writing to Stream_1"); var stream = streams.Open("Stream_1"); await stream.AppendAsync(new { data = "Hello world!" }); Console.WriteLine("Reading from Stream_1"); await stream.ReadAsync(data => { Console.WriteLine($" index {data.Index} => {data.Payload}"); return(Task.FromResult(true)); }); }
public async Task verify_unwind_plain_object() { var poco = new PocoObject("TEST", 42); var streamFactory = new StreamsFactory(_persistence); var stream = streamFactory.Open("poco/42"); await stream.AppendAsync(poco).ConfigureAwait(false); await sut.UnwindAsync().ConfigureAwait(false); var allEvents = sut.UnwindedCollection.FindAll(); Assert.That(allEvents.CountDocuments(), Is.EqualTo(1)); var evt = allEvents.Single(); Assert.That(evt.EventType, Is.EqualTo("PocoObject")); Assert.That((evt.GetEvent() as PocoObject).IntValue, Is.EqualTo(42)); Assert.That((evt.GetEvent() as PocoObject).Value, Is.EqualTo("TEST")); Assert.That(evt.PartitionId, Is.EqualTo("poco/42")); }