diff --git a/Client.UnitTests/TestDataProvider.cs b/Client.UnitTests/TestDataProvider.cs index 519926bf..b3fa48a9 100644 --- a/Client.UnitTests/TestDataProvider.cs +++ b/Client.UnitTests/TestDataProvider.cs @@ -33,6 +33,21 @@ public static IEnumerable Provider() }, new ActivateJobsResponse(), (RequestCreator) (zeebeClient => zeebeClient.NewActivateJobsCommand().JobType("type").MaxJobsToActivate(12))); + yield return new TestCaseData( + new TopologyRequest + { + ProcessInstanceKey = 12113 + }, new TopologyResponse(), + (RequestCreator) + (zeebeClient => zeebeClient.TopologyRequest())); + yield return new TestCaseData( + new UpdateRetries + { + ProcessInstanceKey = 12113 + }, new UpdateRetriesResponse() + { RequestCreator} + (ZeebeClientTest => ZeebeClient.NewUpdateRetriesCommand())); } + } } \ No newline at end of file diff --git a/Client/Api/Commands/ITopologyRequestStep1.cs b/Client/Api/Commands/ITopologyRequestStep1.cs index a88add2b..5231ad0a 100644 --- a/Client/Api/Commands/ITopologyRequestStep1.cs +++ b/Client/Api/Commands/ITopologyRequestStep1.cs @@ -16,7 +16,7 @@ namespace Zeebe.Client.Api.Commands { - public interface ITopologyRequestStep1 : IFinalCommandStep + public interface ITopologyRequestStep1 : IFinalCommandWithRetryStep { } } diff --git a/Client/Api/Commands/IUpdateRetriesCommandStep1.cs b/Client/Api/Commands/IUpdateRetriesCommandStep1.cs index d8b66a38..0c4346c3 100644 --- a/Client/Api/Commands/IUpdateRetriesCommandStep1.cs +++ b/Client/Api/Commands/IUpdateRetriesCommandStep1.cs @@ -19,8 +19,8 @@ public interface IUpdateRetriesCommandStep1 IUpdateRetriesCommandStep2 Retries(int retries); } - public interface IUpdateRetriesCommandStep2 : IFinalCommandStep + public interface IUpdateRetriesCommandStep2 : IFinalCommandWithRetryStep { - // the place for new optional parameters + // the place for new optional parameters } } \ No newline at end of file diff --git a/Client/Impl/Commands/TopologyRequestCommand.cs b/Client/Impl/Commands/TopologyRequestCommand.cs index d51c6c92..c1193059 100644 --- a/Client/Impl/Commands/TopologyRequestCommand.cs +++ b/Client/Impl/Commands/TopologyRequestCommand.cs @@ -27,9 +27,11 @@ public class TopologyRequestCommand : ITopologyRequestStep1 { private readonly Gateway.GatewayClient gatewayClient; private readonly TopologyRequest request = new TopologyRequest(); + private readonly IAsyncRetryStrategy asyncRetryStrategy; - public TopologyRequestCommand(Gateway.GatewayClient client) + public TopologyRequestCommand(Gateway.GatewayClient client, IAsyncRetryStrategy asyncRetryStrategy) { + gatewayClient = client; } @@ -41,6 +43,11 @@ public async Task Send(TimeSpan? timeout = null, CancellationToken to return new Topology(response); } + public async Task SendWithRetry(TimeSpan? timespan = null, CancellationToken token = default) + { + return await asyncRetryStrategy.DoWithRetry(() => Send(timespan, token)); + } + public async Task Send(CancellationToken cancellationToken) { return await Send(token: cancellationToken); diff --git a/Client/Impl/Commands/UpdateRetriesCommand.cs b/Client/Impl/Commands/UpdateRetriesCommand.cs index c742408a..d6f6adba 100644 --- a/Client/Impl/Commands/UpdateRetriesCommand.cs +++ b/Client/Impl/Commands/UpdateRetriesCommand.cs @@ -12,6 +12,7 @@ public class UpdateRetriesCommand : IUpdateRetriesCommandStep1, IUpdateRetriesCo { private readonly UpdateJobRetriesRequest request; private readonly Gateway.GatewayClient client; + private readonly IAsyncRetryStrategy asyncRetryStrategy; public UpdateRetriesCommand(Gateway.GatewayClient client, long jobKey) { @@ -39,5 +40,10 @@ public async Task Send(CancellationToken cancellationTok { return await Send(token: cancellationToken); } + + public async Task SendWithRetry(CancellationToken cancellationToken) + { + return await asyncRetryStrategy.DoWithRetry(() => Send(token: cancellationToken)); + } } } \ No newline at end of file diff --git a/Client/ZeebeClient.cs b/Client/ZeebeClient.cs index b84a08ae..0e419641 100644 --- a/Client/ZeebeClient.cs +++ b/Client/ZeebeClient.cs @@ -122,7 +122,7 @@ public IFailJobCommandStep1 NewFailCommand(long jobKey) public IUpdateRetriesCommandStep1 NewUpdateRetriesCommand(long jobKey) { - return new UpdateRetriesCommand(gatewayClient, jobKey); + return new UpdateRetriesCommand(gatewayClient, asyncRetryStrategy, jobKey); } public IThrowErrorCommandStep1 NewThrowErrorCommand(long jobKey) @@ -164,7 +164,7 @@ public IPublishMessageCommandStep1 NewPublishMessageCommand() return new PublishMessageCommand(gatewayClient); } - public ITopologyRequestStep1 TopologyRequest() => new TopologyRequestCommand(gatewayClient); + public ITopologyRequestStep1 TopologyRequest() => new TopologyRequestCommand(gatewayClient, asyncRetryStrategy); public void Dispose() {