Skip to content

Commit

Permalink
Merge pull request #678 from brandon-mork/main
Browse files Browse the repository at this point in the history
Issue 677 Add Variables property to FailJobCommand
  • Loading branch information
ChrisKujawa authored May 23, 2024
2 parents cb12dfc + 894bbbe commit 9ae2138
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Building the C# client from source

The core functionality and API lies in the `Client` project sub folder.
Simply open the solution with one of your prefered IDE's (like VS Studio, Rider or Mono).
Simply open the solution with one of your preferred IDE's (like VS Studio, Rider or Mono).
It should also be possible to build the solution via `msbuild`.

The `Client-test` project contains as the name states the tests of the Client API.
Expand Down
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 9ae2138

Please sign in to comment.