Skip to content

Commit

Permalink
Merge pull request #79 from BrunoZell/projection-reset
Browse files Browse the repository at this point in the history
Add projection reset to client
  • Loading branch information
hayley-jean committed Oct 20, 2020
2 parents d88ac61 + d53b089 commit 2730403
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ public partial class EventStoreProjectionManagementClient {
await call.ResponseAsync.ConfigureAwait(false);
}

/// <summary>
/// Resets a projection. This will re-emit events. Streams that are written to from the projection will also be soft deleted.
/// </summary>
/// <param name="name"></param>
/// <param name="userCredentials"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task ResetAsync(string name, UserCredentials? userCredentials = null,
CancellationToken cancellationToken = default) {
using var call = _client.ResetAsync(new ResetReq {
Options = new ResetReq.Types.Options {
Name = name,
WriteCheckpoint = true
}
}, EventStoreCallOptions.Create(Settings, Settings.OperationOptions, userCredentials, cancellationToken));
await call.ResponseAsync.ConfigureAwait(false);
}

/// <summary>
/// Aborts a projection. Saves the projection's checkpoint.
/// </summary>
Expand Down
26 changes: 26 additions & 0 deletions test/EventStore.Client.ProjectionManagement.Tests/reset.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Linq;
using System.Threading.Tasks;
using Xunit;

namespace EventStore.Client {
public class reset : IClassFixture<reset.Fixture> {
private readonly Fixture _fixture;

public reset(Fixture fixture) {
_fixture = fixture;
}

[Fact]
public async Task status_is_running() {
var name = StandardProjections.Names.First();
await _fixture.Client.ResetAsync(name, TestCredentials.Root);
var result = await _fixture.Client.GetStatusAsync(name, TestCredentials.Root);
Assert.Equal("Running", result.Status);
}

public class Fixture : EventStoreClientFixture {
protected override Task Given() => Task.CompletedTask;
protected override Task When() => Task.CompletedTask;
}
}
}

0 comments on commit 2730403

Please sign in to comment.