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 restarting persistent subscriptions #68

Merged
merged 2 commits into from
Aug 5, 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
1 change: 1 addition & 0 deletions src/EventStore.Client.Common/protos/operations.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ service Operations {
rpc MergeIndexes (Empty) returns (Empty);
rpc ResignNode (Empty) returns (Empty);
rpc SetNodePriority (SetNodePriorityReq) returns (Empty);
rpc RestartPersistentSubscriptions (Empty) returns (Empty);
}

message StartScavengeReq {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,17 @@ public partial class EventStoreOperationsClient {
await _client.SetNodePriorityAsync(new SetNodePriorityReq {Priority = nodePriority},
EventStoreCallOptions.Create(Settings, Settings.OperationOptions, userCredentials, cancellationToken));
}

/// <summary>
/// Restart persistent subscriptions
/// </summary>
/// <param name="userCredentials"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task RestartPersistentSubscriptions(UserCredentials? userCredentials = null,
CancellationToken cancellationToken = default) {
await _client.RestartPersistentSubscriptionsAsync(EmptyResult,
EventStoreCallOptions.Create(Settings, Settings.OperationOptions, userCredentials, cancellationToken));
}
}
}
38 changes: 9 additions & 29 deletions test/EventStore.Client.Operations.Tests/admin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,23 @@ public class admin : IClassFixture<admin.Fixture> {
}

[Fact]
public async Task shutdown_does_not_throw() {
await _fixture.Client.ShutdownAsync(userCredentials: TestCredentials.Root);
}

[Fact]
public async Task shutdown_without_credentials_throws() {
await Assert.ThrowsAsync<AccessDeniedException>(() => _fixture.Client.ShutdownAsync());
}

[Fact]
public async Task set_node_priority_does_not_throw() {
await _fixture.Client.SetNodePriorityAsync(1000, TestCredentials.Root);
}

[Fact]
public async Task set_node_priority_without_credentials_throws() {
await Assert.ThrowsAsync<AccessDeniedException>(() => _fixture.Client.SetNodePriorityAsync(1000));
}

[Fact]
public async Task resign_node_does_not_throw() {
await _fixture.Client.ResignNodeAsync(TestCredentials.Root);
public async Task merge_indexes_does_not_throw() {
await _fixture.Client.MergeIndexesAsync(TestCredentials.Root);
}

[Fact]
public async Task resign_node_without_credentials_throws() {
await Assert.ThrowsAsync<AccessDeniedException>(() => _fixture.Client.ResignNodeAsync());
public async Task merge_indexes_without_credentials_throws() {
await Assert.ThrowsAsync<AccessDeniedException>(() => _fixture.Client.MergeIndexesAsync());
}

[Fact]
public async Task merge_indexes_does_not_throw() {
await _fixture.Client.MergeIndexesAsync(TestCredentials.Root);
public async Task restart_persistent_subscriptions_does_not_throw() {
await _fixture.Client.RestartPersistentSubscriptions(TestCredentials.Root);
}

[Fact]
public async Task merge_indexes_without_credentials_throws() {
await Assert.ThrowsAsync<AccessDeniedException>(() => _fixture.Client.MergeIndexesAsync());
public async Task restart_persistent_subscriptions_without_credentials_throws() {
await Assert.ThrowsAsync<AccessDeniedException>(() => _fixture.Client.RestartPersistentSubscriptions());
}

public class Fixture : EventStoreClientFixture {
Expand Down
27 changes: 27 additions & 0 deletions test/EventStore.Client.Operations.Tests/admin_resign_node.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Threading.Tasks;
using Xunit;

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

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

[Fact]
public async Task resign_node_does_not_throw() {
await _fixture.Client.ResignNodeAsync(TestCredentials.Root);
}

[Fact]
public async Task resign_node_without_credentials_throws() {
await Assert.ThrowsAsync<AccessDeniedException>(() => _fixture.Client.ResignNodeAsync());
}

public class Fixture : EventStoreClientFixture {
protected override Task Given() => Task.CompletedTask;
protected override Task When() => Task.CompletedTask;
}
}
}
27 changes: 27 additions & 0 deletions test/EventStore.Client.Operations.Tests/admin_shutdown_node.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Threading.Tasks;
using Xunit;

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

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

[Fact]
public async Task shutdown_does_not_throw() {
await _fixture.Client.ShutdownAsync(userCredentials: TestCredentials.Root);
}

[Fact]
public async Task shutdown_without_credentials_throws() {
await Assert.ThrowsAsync<AccessDeniedException>(() => _fixture.Client.ShutdownAsync());
}

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