public async Task InitializeAsync( CancellationToken ct) { try { await client.SoftDeleteAsync(Guid.NewGuid().ToString(), StreamState.Any, cancellationToken : ct); } catch (Exception ex) { var error = new ConfigurationError("GetEventStore cannot connect to event store."); throw new ConfigurationException(error, ex); } }
public async Task <bool> DeleteAggregateRoot <T>(Guid id) where T : AggregateRootWithEvents { String streamId = GetStreamId <T>(id); await _client.SoftDeleteAsync(streamId, StreamState.Any); return(true); }
//[Obsolete("This doesn't care for other operations. In the future it will be moved to session or renamed.")] public async Task SoftDelete(TId selector) { var readResult = await eventReader.ReadFrom(selector.ToString()); if (readResult.streamExists) { await client.SoftDeleteAsync(selector.ToString(), StreamState.Any); } }
private async Task TryCleanECStream() { try { await _eventStore.SoftDeleteAsync(InterfaceConst.PSPrime, StreamState.Any); } catch (Exception ex) { Console.WriteLine(ex.Message); } return; }
private async Task EventStore() { await _eventStore.SoftDeleteAsync(InterfaceConst.PSHello, StreamState.Any); var events = new List <EventData>(); for (int i = 1; i < 10; i++) { var evt = $"Good morning, {i}!"; events.Add(evt.GetEvent()); } await _eventStore.AppendToStreamAsync( InterfaceConst.PSHello, StreamState.Any, events ); }
public async Task SaysHello_ES() { // Arrange var grain = _cluster.Client.GetGrain <IHello>(3); await grain.Consume(); await _eventStore.SoftDeleteAsync(InterfaceConst.PSHello, StreamState.Any); var evt = $"teste"; var vnt = new EventData( evt.GetHashCode().ToUuid(), evt.GetType().ToString(), JsonSerializer.SerializeToUtf8Bytes(evt) ); // Act await _eventStore.AppendToStreamAsync( InterfaceConst.PSHello, StreamState.Any, new[] { vnt } ); }
static async Task Main(string[] args) { //esdb://localhost:2113?tls=false var settings = EventStoreClientSettings .Create("esdb://localhost:2113?tls=false"); var client = new EventStoreClient(settings); //await TestReadFromtombstoned(client); var projectionClient = new EventStoreProjectionManagementClient(settings); var operationsClient = new EventStoreOperationsClient(settings); await client.SoftDeleteAsync("dokimi-1", StreamState.Any); await client.SoftDeleteAsync("dokimi-2", StreamState.Any); await client.SoftDeleteAsync("dokimi-3", StreamState.Any); //await projectionClient.DisableAsync("$by_category"); //var result = await operationsClient.StartScavengeAsync(); //await Task.Delay(TimeSpan.FromSeconds(20)); //await projectionClient.EnableAsync("$by_category"); //await projectionClient.ResetAsync("$by_category"); //var readDeltedStreamResult = client.ReadStreamAsync(Direction.Forwards, "test", StreamPosition.Start); //Console.WriteLine("Stream existed: {0}\nSteam was empty: {1}", // await readDeltedStreamResult.ReadState, // await readDeltedStreamResult.CountAsync()); var data = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new Data() { Value = 5 })); var writeResult = await client.AppendToStreamAsync("dokimi-1", StreamRevision.FromInt64(-1), new[] { new EventData(Uuid.NewUuid(), "TestType", data) }); writeResult = await client.AppendToStreamAsync("dokimi-2", StreamRevision.FromInt64(-1), new[] { new EventData(Uuid.NewUuid(), "TestType", data) }); writeResult = await client.AppendToStreamAsync("dokimi-3", StreamRevision.FromInt64(-1), new[] { new EventData(Uuid.NewUuid(), "TestType", data) }); await Task.Delay(TimeSpan.FromSeconds(10)); var readResult = client.ReadStreamAsync(Direction.Forwards, "$ce-dokimi", StreamPosition.Start, resolveLinkTos: true); var isSuccess = await readResult.ReadState; var events = await readResult.Where(x => x.Event != null).ToListAsync(); var eventCount = events.Count; var readResultStream = client.ReadStreamAsync(Direction.Forwards, "dokimi-2", StreamPosition.Start); var isSuccessStream = await readResultStream.ReadState; var eventsInStream = await readResultStream.ToListAsync(); var eventCountStream = eventsInStream.Count; Console.WriteLine("Could read stream: {0}", isSuccess); Console.WriteLine("Found {0} events", eventCount); Console.WriteLine("Press any key to exit!"); Console.ReadKey(); }
public Task <DeleteResult> SoftDeleteAsync(string streamName, StreamRevision expectedRevision, Action <EventStoreClientOperationOptions> configureOperationOptions = null, UserCredentials userCredentials = null, CancellationToken cancellationToken = new CancellationToken()) { return(Client.SoftDeleteAsync(streamName, expectedRevision, configureOperationOptions, userCredentials, cancellationToken)); }