protected async Task GenerateEmptyUntil(Int64 positionTo) { IChunk chunk; do { chunk = await _persistence.AppendAsync("Empty", null).ConfigureAwait(false); lastUsedPosition = chunk.Position; } while (chunk.Position < positionTo); }
public Task <IChunk> AppendAsync(string partitionId, long index, object payload, string operationId, CancellationToken cancellationToken) { return(Track.Profile(Timers.Append, () => _persistence.AppendAsync(partitionId, index, payload, operationId, cancellationToken) )); }
public static Task <IChunk> AppendAsync( this IPersistence store, string partitionId, object payload ) { return(store.AppendAsync(partitionId, -1, payload, null, CancellationToken.None)); }
private void task_worker(IPersistence store) { var all = _iterations.Select(i => Task.Run(async() => await store.AppendAsync("Stream_1", i, new { data = "this is a test" }) )); Task.WhenAll(all).GetAwaiter().GetResult(); }
public static Task <IChunk> AppendAsync( this IPersistence persistence, string partitionId, long index, object payload ) { return(persistence.AppendAsync(partitionId, index, payload, null, CancellationToken.None)); }
public async Task persist_should_be_recorded() { await _store.AppendAsync("empty", 0, null).ConfigureAwait(false); Assert.Equal(1, _profile.PersistCounter.Calls); Assert.Equal(0, _profile.DeleteCounter.Calls); Assert.Equal(0, _profile.StoreScanCounter.Calls); Assert.Equal(0, _profile.ReadForwardCounter.Calls); Assert.Equal(0, _profile.ReadBackwardCounter.Calls); Assert.Equal(0, _profile.ReadSingleBackwardCounter.Calls); }
public static Task Run(IPersistence store, IEnumerable <int> iterations) { var list = new List <Task>(); foreach (var iteration in iterations) { list.Add(store.AppendAsync("Stream_1", iteration, new { data = "this is a test" })); } return(Task.WhenAll(list.ToArray())); }
public async void persist_should_be_recorded() { await _store.AppendAsync("empty", 0, null); Assert.Equal(1, _profile.PersistCounter.Calls); Assert.Equal(0, _profile.DeleteCounter.Calls); Assert.Equal(0, _profile.StoreScanCounter.Calls); Assert.Equal(0, _profile.ReadForwardCounter.Calls); Assert.Equal(0, _profile.ReadBackwardCounter.Calls); Assert.Equal(0, _profile.PeekCounter.Calls); }
public async Task <IChunk> AppendAsync( string partitionId, long index, object payload, string operationId, CancellationToken cancellationToken) { _logger.LogDebug("Start PersistAsync({partitionId}, {index})", partitionId, index); var result = await _persistence.AppendAsync(partitionId, index, payload, operationId, cancellationToken).ConfigureAwait(false); _logger.LogDebug("End PersistAsync({partitionId}, {index}) => {Position}", partitionId, index, result?.Position); return(result); }
public async Task AddAsync(string snapshotPartitionId, SnapshotInfo snapshot, CancellationToken cancellationToken) { if (snapshot == null || snapshot.IsEmpty) { return; } try { await _store.AppendAsync(snapshotPartitionId, snapshot.SourceVersion, snapshot, null, cancellationToken).ConfigureAwait(false); } catch (DuplicateStreamIndexException) { // already stored } }
private async Task async_worker(IPersistence store) { var publish = new ActionBlock <long>(async i => { await store.AppendAsync("Stream_1", i, new { data = "this is a test" }); }, new ExecutionDataflowBlockOptions() { MaxDegreeOfParallelism = Environment.ProcessorCount }); foreach (var iteration in _iterations) { await publish.SendAsync(iteration); } publish.Complete(); await publish.Completion; }
protected override async Task ProcessAsync(Signal payload) { Track.Inc(Counters.ReceivedMessages); await Track.Profile(Timers.RequestTimer, async() => { while (true) { try { await _persistence.AppendAsync( payload.DeviceId, DateTime.UtcNow.Ticks, payload ).ConfigureAwait(false); return; } catch (DuplicateStreamIndexException) { // retry with new ticks } } }).ConfigureAwait(false); }
public Task <IChunk> AppendAsync(string partitionId, long index, object payload, string operationId, CancellationToken cancellationToken) { return(PersistCounter.CaptureAsync(() => _store.AppendAsync(partitionId, index, payload, operationId, cancellationToken) )); }
public async Task <long> PersistEventAsync(string actorName, long index, object @event) { await _events.AppendAsync(actorName, index, @event).ConfigureAwait(false); return(index++); // TODO -> check sources, not really needed imho }
private void paralell_worker(IPersistence store) { _iterations.ForEachAsync(Workers, i => store.AppendAsync("Stream_1", i, new { data = "this is a test" }) ).ConfigureAwait(false).GetAwaiter().GetResult(); }
public async Task PersistSnapshotAsync(string actorName, long index, object snapshot) { await _snapshots.AppendAsync(actorName, index, snapshot).ConfigureAwait(false); }