From 2a5ce6872e54d9f8bde7843b66a6d5ab33d73f96 Mon Sep 17 00:00:00 2001 From: Brandon Mork Date: Sat, 11 May 2024 10:12:48 -0400 Subject: [PATCH 1/2] feat: add variables to fail command --- Client.UnitTests/FailJobTest.cs | 5 ++++- Client/Api/Commands/IFailJobCommandStep1.cs | 8 ++++++++ Client/Impl/Commands/FailJobCommand.cs | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Client.UnitTests/FailJobTest.cs b/Client.UnitTests/FailJobTest.cs index 2312b295..dba263a4 100644 --- a/Client.UnitTests/FailJobTest.cs +++ b/Client.UnitTests/FailJobTest.cs @@ -16,12 +16,14 @@ 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 @@ -29,6 +31,7 @@ await ZeebeClient.NewFailCommand(jobKey) .Retries(2) .ErrorMessage("This job failed!") .RetryBackOff(TimeSpan.FromMilliseconds(1562.5)) + .Variables(variables) .Send(); // then diff --git a/Client/Api/Commands/IFailJobCommandStep1.cs b/Client/Api/Commands/IFailJobCommandStep1.cs index 0633d3a8..52194caf 100644 --- a/Client/Api/Commands/IFailJobCommandStep1.cs +++ b/Client/Api/Commands/IFailJobCommandStep1.cs @@ -59,5 +59,13 @@ public interface IFailJobCommandStep2 : IFinalCommandWithRetryStep IFailJobCommandStep2 RetryBackOff(TimeSpan retryBackOff); + + /// + /// Set the variables to fail the job with. + /// + /// the variables (JSON) as String. + /// the builder for this command. Call to complete the command and send it + /// to the broker. + IFailJobCommandStep2 Variables(string variables); } } \ No newline at end of file diff --git a/Client/Impl/Commands/FailJobCommand.cs b/Client/Impl/Commands/FailJobCommand.cs index 237360b1..9e859467 100644 --- a/Client/Impl/Commands/FailJobCommand.cs +++ b/Client/Impl/Commands/FailJobCommand.cs @@ -59,6 +59,12 @@ public IFailJobCommandStep2 RetryBackOff(TimeSpan retryBackOff) return this; } + public IFailJobCommandStep2 Variables(string variables) + { + request.Variables = variables; + return this; + } + public async Task Send(TimeSpan? timeout = null, CancellationToken token = default) { var asyncReply = gatewayClient.FailJobAsync(request, deadline: timeout?.FromUtcNow(), cancellationToken: token); From 894bbbecb9e633f81420ded2142a9906c4da2962 Mon Sep 17 00:00:00 2001 From: Brandon Mork Date: Sat, 11 May 2024 10:13:25 -0400 Subject: [PATCH 2/2] docs: fix typo --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d24f4921..471dd200 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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.