Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add projection reset to client #79

Merged
merged 2 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ public async Task EnableAsync(string name, UserCredentials? userCredentials = nu
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;
}
}
}