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

feature: updated ResolveIncidentCommand so that it would run with ret… #334

Merged
merged 1 commit into from
Oct 7, 2021
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
12 changes: 9 additions & 3 deletions Client.UnitTests/TestDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public static IEnumerable<TestCaseData> Provider()
new TopologyResponse(),
(RequestCreator<ITopology>)
(zeebeClient => zeebeClient.TopologyRequest()));

yield return new TestCaseData(
new UpdateJobRetriesRequest
{
Expand All @@ -61,6 +60,13 @@ public static IEnumerable<TestCaseData> Provider()
}, new GatewayProtocol.ThrowErrorResponse(),
(RequestCreator<IThrowErrorResponse>)
(zeebeClient => zeebeClient.NewThrowErrorCommand(12113).ErrorCode("Code 13").ErrorMessage("This is a business error!")));
}
yield return new TestCaseData(
new ResolveIncidentRequest
{
IncidentKey = 1201321
}, new GatewayProtocol.ResolveIncidentResponse(),
(RequestCreator<IResolveIncidentResponse>)
(zeebeClient => zeebeClient.NewResolveIncidentCommand(1201321)));
}
}
}
}
2 changes: 1 addition & 1 deletion Client/Api/Commands/IResolveIncidentCommandStep1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Zeebe.Client.Api.Commands
{
public interface IResolveIncidentCommandStep1 : IFinalCommandStep<IResolveIncidentResponse>
public interface IResolveIncidentCommandStep1 : IFinalCommandWithRetryStep<IResolveIncidentResponse>
{
// the place for new optional parameters
}
Expand Down
10 changes: 9 additions & 1 deletion Client/Impl/Commands/ResolveIncidentCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading.Tasks;
using GatewayProtocol;
using Zeebe.Client.Api.Commands;
using Zeebe.Client.Api.Misc;
using Zeebe.Client.Api.Responses;
using ResolveIncidentResponse = Zeebe.Client.Impl.Responses.ResolveIncidentResponse;

Expand All @@ -12,14 +13,16 @@ public class ResolveIncidentCommand : IResolveIncidentCommandStep1
{
private readonly ResolveIncidentRequest request;
private readonly Gateway.GatewayClient client;
private readonly IAsyncRetryStrategy asyncRetryStrategy;

public ResolveIncidentCommand(Gateway.GatewayClient client, long incidentKey)
public ResolveIncidentCommand(Gateway.GatewayClient client, IAsyncRetryStrategy asyncRetryStrategy, long incidentKey)
{
request = new ResolveIncidentRequest
{
IncidentKey = incidentKey
};
this.client = client;
this.asyncRetryStrategy = asyncRetryStrategy;
}

public async Task<IResolveIncidentResponse> Send(TimeSpan? timeout = null, CancellationToken token = default)
Expand All @@ -33,5 +36,10 @@ public async Task<IResolveIncidentResponse> Send(CancellationToken cancellationT
{
return await Send(token: cancellationToken);
}
public async Task<IResolveIncidentResponse> SendWithRetry(TimeSpan? timespan = null, CancellationToken token = default)
{
return await asyncRetryStrategy.DoWithRetry(() => Send(timespan, token));
}

}
}
2 changes: 1 addition & 1 deletion Client/ZeebeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public ISetVariablesCommandStep1 NewSetVariablesCommand(long elementInstanceKey)

public IResolveIncidentCommandStep1 NewResolveIncidentCommand(long incidentKey)
{
return new ResolveIncidentCommand(gatewayClient, incidentKey);
return new ResolveIncidentCommand(gatewayClient, asyncRetryStrategy, incidentKey);
}

public IPublishMessageCommandStep1 NewPublishMessageCommand()
Expand Down