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

feat: allowed to set retryBackOff parameter of FailJobCommand #482

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions Client.UnitTests/FailJobTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ public async Task ShouldSendRequestAsExpected()
{
JobKey = jobKey,
ErrorMessage = errorMessage,
Retries = 2
Retries = 2,
RetryBackOff = 1562
};

// when
await ZeebeClient.NewFailCommand(jobKey).Retries(2).ErrorMessage("This job failed!").Send();
await ZeebeClient.NewFailCommand(jobKey)
.Retries(2)
.ErrorMessage("This job failed!")
.RetryBackOff(TimeSpan.FromMilliseconds(1562.5))
.Send();

// then
var actualRequest = TestService.Requests[typeof(FailJobRequest)][0];
Expand Down
12 changes: 12 additions & 0 deletions Client/Api/Commands/IFailJobCommandStep1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using Zeebe.Client.Api.Responses;

namespace Zeebe.Client.Api.Commands
Expand Down Expand Up @@ -47,5 +48,16 @@ public interface IFailJobCommandStep2 : IFinalCommandWithRetryStep<IFailJobRespo
/// to the broker.
/// </returns>
IFailJobCommandStep2 ErrorMessage(string errorMsg);

/// <summary>
/// Set the backoff timeout for the next retry of this job.
///
/// </summary>
///
/// <param name="retryBackOff">the backoff timeout for the next retry of this job.</param>
/// <returns>the builder for this command. Call <see cref="IFinalCommandStep{T}.Send"/> to complete the command and send it
/// to the broker.
/// </returns>
IFailJobCommandStep2 RetryBackOff(TimeSpan retryBackOff);
}
}
6 changes: 6 additions & 0 deletions Client/Impl/Commands/FailJobCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ public IFailJobCommandStep2 ErrorMessage(string errorMsg)
return this;
}

public IFailJobCommandStep2 RetryBackOff(TimeSpan retryBackOff)
{
request.RetryBackOff = (long)retryBackOff.TotalMilliseconds;
return this;
}

public async Task<IFailJobResponse> Send(TimeSpan? timeout = null, CancellationToken token = default)
{
var asyncReply = gatewayClient.FailJobAsync(request, deadline: timeout?.FromUtcNow(), cancellationToken: token);
Expand Down