Skip to content

Commit

Permalink
feat: add variables to fail command
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-mork committed May 23, 2024
1 parent 7550c64 commit 2a5ce68
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Client.UnitTests/FailJobTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,22 @@ public async Task ShouldSendRequestAsExpected()
// given
const string errorMessage = "This job failed!";
const int jobKey = 255;
const string variables = "{\"foo\":23}";
var expectedRequest = new FailJobRequest
{
JobKey = jobKey,
ErrorMessage = errorMessage,
Retries = 2,
RetryBackOff = 1562
RetryBackOff = 1562,
Variables = variables
};

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

// then
Expand Down
8 changes: 8 additions & 0 deletions Client/Api/Commands/IFailJobCommandStep1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,13 @@ public interface IFailJobCommandStep2 : IFinalCommandWithRetryStep<IFailJobRespo
/// to the broker.
/// </returns>
IFailJobCommandStep2 RetryBackOff(TimeSpan retryBackOff);

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

public IFailJobCommandStep2 Variables(string variables)
{
request.Variables = variables;
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

0 comments on commit 2a5ce68

Please sign in to comment.