diff --git a/Client/IZeebeClient.cs b/Client/IZeebeClient.cs index fd187ae3..d3afda3e 100644 --- a/Client/IZeebeClient.cs +++ b/Client/IZeebeClient.cs @@ -16,295 +16,294 @@ using Zeebe.Client.Api.Commands; using Zeebe.Client.Api.Worker; -namespace Zeebe.Client +namespace Zeebe.Client; + +/// +/// The client to communicate with a Zeebe gateway/cluster. +/// +public interface IZeebeClient : IJobClient, IDisposable { /// - /// The client to communicate with a Zeebe gateway/cluster. + /// Registers a new job worker for jobs of a given type. /// - public interface IZeebeClient : IJobClient, IDisposable - { - /// - /// Registers a new job worker for jobs of a given type. - /// - /// - /// - /// After registration, the broker activates available jobs and assigns them to this worker. It - /// then publishes them to the client. The given worker is called for every received job, works on - /// them and eventually completes them. - /// - /// - /// - /// using(IJobWorker worker = zeebeClient - /// .NewWorker() - /// .jobType("payment") - /// .handler(paymentHandler) - /// .open()) - /// { - /// ... - /// } - /// - /// Example JobHandler implementation: - /// - /// - /// var handler = (client, job) => - /// { - /// String json = job.Variables; - /// // modify variables - /// - /// client - /// .CompleteCommand(job.Key) - /// .Variables(json) - /// .Send(); - /// }; - /// - /// - /// - /// The handler must be thread-safe. - /// a builder for the worker registration - IJobWorkerBuilderStep1 NewWorker(); + /// + /// + /// After registration, the broker activates available jobs and assigns them to this worker. It + /// then publishes them to the client. The given worker is called for every received job, works on + /// them and eventually completes them. + /// + /// + /// + /// using(IJobWorker worker = zeebeClient + /// .NewWorker() + /// .jobType("payment") + /// .handler(paymentHandler) + /// .open()) + /// { + /// ... + /// } + /// + /// Example JobHandler implementation: + /// + /// + /// var handler = (client, job) => + /// { + /// String json = job.Variables; + /// // modify variables + /// + /// client + /// .CompleteCommand(job.Key) + /// .Variables(json) + /// .Send(); + /// }; + /// + /// + /// + /// The handler must be thread-safe. + /// a builder for the worker registration. + IJobWorkerBuilderStep1 NewWorker(); - /// - /// Command to activate multiple jobs of a given type. - /// - /// - /// - /// - /// zeebeClient - /// .NewActivateJobsCommand() - /// .JobType("payment") - /// .maxJobsToActivate(10) - /// .WorkerName("paymentWorker") - /// .Timeout(TimeSpan.FromMinutes(10)) - /// .Send(); - /// - /// - /// - /// - /// The command will try to use maxJobsToActivate - /// for given jobType. If less - /// then the requested maxJobsToActivate jobs of the - /// jobType are available for - /// activation the returned list will have fewer elements. - /// - /// - /// - /// a builder for the command - /// - IActivateJobsCommandStep1 NewActivateJobsCommand(); + /// + /// Command to activate multiple jobs of a given type. + /// + /// + /// + /// + /// zeebeClient + /// .NewActivateJobsCommand() + /// .JobType("payment") + /// .maxJobsToActivate(10) + /// .WorkerName("paymentWorker") + /// .Timeout(TimeSpan.FromMinutes(10)) + /// .Send(); + /// + /// + /// + /// + /// The command will try to use maxJobsToActivate + /// for given jobType. If less + /// then the requested maxJobsToActivate jobs of the + /// jobType are available for + /// activation the returned list will have fewer elements. + /// + /// + /// + /// a builder for the command. + /// + IActivateJobsCommandStep1 NewActivateJobsCommand(); - /// - /// Command to update the retries of a job. - /// - /// - /// - /// long jobKey = ..; - /// - /// zeebeClient - /// .NewUpdateRetriesCommand(jobKey) - /// .Retries(3) - /// .Send(); - /// - /// - /// - /// - /// If the given retries are greater than zero then this job will be picked up again by a job - /// subscription and a related incident will be marked as resolved. - /// - /// - /// the key of the job to update - /// - /// - /// a builder for the command - /// - IUpdateRetriesCommandStep1 NewUpdateRetriesCommand(long jobKey); + /// + /// Command to update the retries of a job. + /// + /// + /// + /// long jobKey = ..; + /// + /// zeebeClient + /// .NewUpdateRetriesCommand(jobKey) + /// .Retries(3) + /// .Send(); + /// + /// + /// + /// + /// If the given retries are greater than zero then this job will be picked up again by a job + /// subscription and a related incident will be marked as resolved. + /// + /// + /// the key of the job to update. + /// + /// + /// a builder for the command. + /// + IUpdateRetriesCommandStep1 NewUpdateRetriesCommand(long jobKey); - /// - /// Command to update the timeout of a job. - /// - /// - /// - /// long jobKey = ..; - /// - /// zeebeClient - /// .NewUpdateJobTimeoutCommand(jobKey) - /// .Timeout(new TimeSpan(0, 0, 0, 10)) - /// .Send(); - /// - /// - /// - /// - /// If the job's timeout is zero, the job will be directly retried. - /// - /// - /// the key of the job to update - /// - /// - /// a builder for the command - /// - IUpdateJobTimeoutCommandStep1 NewUpdateJobTimeoutCommand(long jobKey); - - /// - /// Command to deploy new resources, i.e. BPMN process models and DMN decision models. - /// - /// - /// - /// - /// zeebeClient - /// .NewDeployResourceCommand() - /// .AddResourceFile("~/wf/process1.bpmn") - /// .AddResourceFile("~/wf/process2.bpmn") - /// .AddResourceFile("~/dmn/decision.dmn") - /// .Send(); - /// - /// - /// - /// a builder for the deploy command - /// - IDeployResourceCommandStep1 NewDeployCommand(); - - /// - /// Command to evaluate a decision. - /// - /// - /// - /// - /// zeebeClient - /// .NewEvaluateDecisionCommand() - /// .DecisionKey("my-decision") - /// .Variables(json) - /// .Send(); - /// - /// - /// - /// a builder for the deploy command - /// - IEvaluateDecisionCommandStep1 NewEvaluateDecisionCommand(); + /// + /// Command to update the timeout of a job. + /// + /// + /// + /// long jobKey = ..; + /// + /// zeebeClient + /// .NewUpdateJobTimeoutCommand(jobKey) + /// .Timeout(new TimeSpan(0, 0, 0, 10)) + /// .Send(); + /// + /// + /// + /// + /// If the job's timeout is zero, the job will be directly retried. + /// + /// + /// the key of the job to update. + /// + /// + /// a builder for the command. + /// + IUpdateJobTimeoutCommandStep1 NewUpdateJobTimeoutCommand(long jobKey); - /// - /// Command to create/start a new instance of a process. - /// - /// - /// - /// - /// zeebeClient - /// .NewCreateInstanceCommand() - /// .BpmnProcessId("my-process") - /// .LatestVersion() - /// .Variables(json) - /// .Send(); - /// - /// - /// a builder for the command - ICreateProcessInstanceCommandStep1 NewCreateProcessInstanceCommand(); + /// + /// Command to deploy new resources, i.e. BPMN process models and DMN decision models. + /// + /// + /// + /// + /// zeebeClient + /// .NewDeployResourceCommand() + /// .AddResourceFile("~/wf/process1.bpmn") + /// .AddResourceFile("~/wf/process2.bpmn") + /// .AddResourceFile("~/dmn/decision.dmn") + /// .Send(); + /// + /// + /// + /// a builder for the deploy command. + /// + IDeployResourceCommandStep1 NewDeployCommand(); - /// - /// Command to cancel a process instance. - /// - /// - /// - /// zeebeClient - /// .NewCancelInstanceCommand(processInstanceKey) - /// .Send(); - /// - /// - /// - /// processInstanceKey the key which identifies the corresponding process instance - /// - /// - /// a builder for the command - /// - ICancelProcessInstanceCommandStep1 NewCancelInstanceCommand(long processInstanceKey); + /// + /// Command to evaluate a decision. + /// + /// + /// + /// + /// zeebeClient + /// .NewEvaluateDecisionCommand() + /// .DecisionKey("my-decision") + /// .Variables(json) + /// .Send(); + /// + /// + /// + /// a builder for the deploy command. + /// + IEvaluateDecisionCommandStep1 NewEvaluateDecisionCommand(); - /// - /// Command to update the variables of a process instance. - /// - /// - /// - /// zeebeClient - /// .NewSetVariablesCommand(elementInstanceKey) - /// .Variables(json) - /// .Send(); - /// - /// - /// - /// the key of the element instance to set the variables for - /// - /// - /// a builder for the command - /// - ISetVariablesCommandStep1 NewSetVariablesCommand(long elementInstanceKey); + /// + /// Command to create/start a new instance of a process. + /// + /// + /// + /// + /// zeebeClient + /// .NewCreateInstanceCommand() + /// .BpmnProcessId("my-process") + /// .LatestVersion() + /// .Variables(json) + /// .Send(); + /// + /// + /// a builder for the command. + ICreateProcessInstanceCommandStep1 NewCreateProcessInstanceCommand(); - /// - /// Command to resolve an existing incident. - /// - /// - /// - /// zeebeClient - /// .NewResolveIncidentCommand(incidentKey) - /// .Send(); - /// - /// - /// - /// incidentKey the key of the corresponding incident - /// - /// - /// the builder for the command - /// - IResolveIncidentCommandStep1 NewResolveIncidentCommand(long incidentKey); + /// + /// Command to cancel a process instance. + /// + /// + /// + /// zeebeClient + /// .NewCancelInstanceCommand(processInstanceKey) + /// .Send(); + /// + /// + /// + /// processInstanceKey the key which identifies the corresponding process instance. + /// + /// + /// a builder for the command. + /// + ICancelProcessInstanceCommandStep1 NewCancelInstanceCommand(long processInstanceKey); - /// - /// Command to publish a message which can be correlated to a process instance. - /// - /// - /// - /// zeebeClient - /// .NewPublishMessageCommand() - /// .MessageName("order canceled") - /// .CorrelationKey(orderId) - /// .Variables(json) - /// .Send(); - /// - /// - /// - /// a builder for the command - /// - IPublishMessageCommandStep1 NewPublishMessageCommand(); + /// + /// Command to update the variables of a process instance. + /// + /// + /// + /// zeebeClient + /// .NewSetVariablesCommand(elementInstanceKey) + /// .Variables(json) + /// .Send(); + /// + /// + /// + /// the key of the element instance to set the variables for. + /// + /// + /// a builder for the command. + /// + ISetVariablesCommandStep1 NewSetVariablesCommand(long elementInstanceKey); - /// - /// Command to modify a process instance. - /// - /// - /// - /// zeebeClient - /// .NewModifyProcessInstanceCommand(processInstanceKey) - /// .ActivateElement("element1") - /// .And() - /// .ActivateElement("element2") - /// .WithVariables(globalScopedVariables) - /// .WithVariables(localScopedVariables, "element2") - /// .And() - /// .TerminateElement("element3") - /// .SendWithRetry(); - /// - /// - /// The key which identifies the corresponding process instance. - /// - /// a builder for the command. - IModifyProcessInstanceCommandStep1 NewModifyProcessInstanceCommand(long processInstanceKey); + /// + /// Command to resolve an existing incident. + /// + /// + /// + /// zeebeClient + /// .NewResolveIncidentCommand(incidentKey) + /// .Send(); + /// + /// + /// + /// incidentKey the key of the corresponding incident. + /// + /// + /// the builder for the command. + /// + IResolveIncidentCommandStep1 NewResolveIncidentCommand(long incidentKey); - /// - /// Request the current cluster topology. Can be used to inspect which brokers are available at - /// which endpoint and which broker is the leader of which partition. - /// - /// - /// - /// ITopology response = await ZeebeClient.TopologyRequest().Send(); - /// IList{IBrokerInfo} brokers = response.Brokers; - /// - /// - /// - /// the request where you must call - /// - ITopologyRequestStep1 TopologyRequest(); - } -} + /// + /// Command to publish a message which can be correlated to a process instance. + /// + /// + /// + /// zeebeClient + /// .NewPublishMessageCommand() + /// .MessageName("order canceled") + /// .CorrelationKey(orderId) + /// .Variables(json) + /// .Send(); + /// + /// + /// + /// a builder for the command. + /// + IPublishMessageCommandStep1 NewPublishMessageCommand(); + + /// + /// Command to modify a process instance. + /// + /// + /// + /// zeebeClient + /// .NewModifyProcessInstanceCommand(processInstanceKey) + /// .ActivateElement("element1") + /// .And() + /// .ActivateElement("element2") + /// .WithVariables(globalScopedVariables) + /// .WithVariables(localScopedVariables, "element2") + /// .And() + /// .TerminateElement("element3") + /// .SendWithRetry(); + /// + /// + /// The key which identifies the corresponding process instance. + /// + /// a builder for the command. + IModifyProcessInstanceCommandStep1 NewModifyProcessInstanceCommand(long processInstanceKey); + + /// + /// Request the current cluster topology. Can be used to inspect which brokers are available at + /// which endpoint and which broker is the leader of which partition. + /// + /// + /// + /// ITopology response = await ZeebeClient.TopologyRequest().Send(); + /// IList{IBrokerInfo} brokers = response.Brokers; + /// + /// + /// + /// the request where you must call . + /// + ITopologyRequestStep1 TopologyRequest(); +} \ No newline at end of file diff --git a/Client/Impl/Misc/AccessToken.cs b/Client/Impl/Misc/AccessToken.cs index 8046ff15..9a7197b0 100644 --- a/Client/Impl/Misc/AccessToken.cs +++ b/Client/Impl/Misc/AccessToken.cs @@ -6,16 +6,10 @@ namespace Zeebe.Client.Impl.Misc; /// /// AccessToken, which consist of an token and a dueDate (expiryDate). /// -public class AccessToken +public class AccessToken(string token, long dueDate) { - public string Token { get; set; } - public long DueDate { get; set; } - - public AccessToken(string token, long dueDate) - { - Token = token; - DueDate = dueDate; - } + public string Token { get; set; } = token; + public long DueDate { get; set; } = dueDate; public override string ToString() { diff --git a/Client/Impl/Misc/PersistedAccessTokenCache.cs b/Client/Impl/Misc/PersistedAccessTokenCache.cs index add57200..724e0510 100644 --- a/Client/Impl/Misc/PersistedAccessTokenCache.cs +++ b/Client/Impl/Misc/PersistedAccessTokenCache.cs @@ -1,11 +1,9 @@ using System; using System.Collections.Generic; using System.IO; -using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Newtonsoft.Json; -using Zeebe.Client.Api.Builder; namespace Zeebe.Client.Impl.Misc; diff --git a/Client/Impl/Misc/TransientGrpcErrorRetryStrategy.cs b/Client/Impl/Misc/TransientGrpcErrorRetryStrategy.cs index 0ef544c0..79fe5da3 100644 --- a/Client/Impl/Misc/TransientGrpcErrorRetryStrategy.cs +++ b/Client/Impl/Misc/TransientGrpcErrorRetryStrategy.cs @@ -4,40 +4,32 @@ using Grpc.Core; using Zeebe.Client.Api.Misc; -namespace Zeebe.Client.Impl.Misc -{ - public class TransientGrpcErrorRetryStrategy : IAsyncRetryStrategy - { - private static readonly StatusCode[] RetrieableCodes = { StatusCode.Unavailable, StatusCode.ResourceExhausted }; - - private readonly Func waitTimeProvider; +namespace Zeebe.Client.Impl.Misc; - public TransientGrpcErrorRetryStrategy(Func waitTimeProvider) - { - this.waitTimeProvider = waitTimeProvider; - } +public class TransientGrpcErrorRetryStrategy(Func waitTimeProvider) : IAsyncRetryStrategy +{ + private static readonly StatusCode[] RetrieableCodes = [StatusCode.Unavailable, StatusCode.ResourceExhausted]; - public async Task DoWithRetry(Func> action) + public async Task DoWithRetry(Func> action) + { + var retries = 0; + while (true) { - var retries = 0; - while (true) + try + { + var result = await action.Invoke(); + return result; + } + catch (RpcException exception) { - try + if (RetrieableCodes.Contains(exception.StatusCode)) { - var result = await action.Invoke(); - return result; + var waitTime = waitTimeProvider.Invoke(++retries); + await Task.Delay(waitTime); } - catch (RpcException exception) + else { - if (RetrieableCodes.Contains(exception.StatusCode)) - { - var waitTime = waitTimeProvider.Invoke(++retries); - await Task.Delay(waitTime); - } - else - { - throw; - } + throw; } } } diff --git a/Client/Impl/Worker/JobClientWrapper.cs b/Client/Impl/Worker/JobClientWrapper.cs index e5ec55cb..4c8003c9 100644 --- a/Client/Impl/Worker/JobClientWrapper.cs +++ b/Client/Impl/Worker/JobClientWrapper.cs @@ -2,52 +2,51 @@ using Zeebe.Client.Api.Responses; using Zeebe.Client.Api.Worker; -namespace Zeebe.Client.Impl.Worker +namespace Zeebe.Client.Impl.Worker; + +internal class JobClientWrapper : IJobClient { - internal class JobClientWrapper : IJobClient + public static JobClientWrapper Wrap(IJobClient client) + { + return new JobClientWrapper(client); + } + + public bool ClientWasUsed { get; private set; } + + private IJobClient Client { get; } + + private JobClientWrapper(IJobClient client) + { + Client = client; + ClientWasUsed = false; + } + + public ICompleteJobCommandStep1 NewCompleteJobCommand(long jobKey) + { + ClientWasUsed = true; + return Client.NewCompleteJobCommand(jobKey); + } + + public IFailJobCommandStep1 NewFailCommand(long jobKey) + { + ClientWasUsed = true; + return Client.NewFailCommand(jobKey); + } + + public IThrowErrorCommandStep1 NewThrowErrorCommand(long jobKey) + { + ClientWasUsed = true; + return Client.NewThrowErrorCommand(jobKey); + } + + public void Reset() + { + ClientWasUsed = false; + } + + public ICompleteJobCommandStep1 NewCompleteJobCommand(IJob activatedJob) { - public static JobClientWrapper Wrap(IJobClient client) - { - return new JobClientWrapper(client); - } - - public bool ClientWasUsed { get; private set; } - - private IJobClient Client { get; } - - private JobClientWrapper(IJobClient client) - { - Client = client; - ClientWasUsed = false; - } - - public ICompleteJobCommandStep1 NewCompleteJobCommand(long jobKey) - { - ClientWasUsed = true; - return Client.NewCompleteJobCommand(jobKey); - } - - public IFailJobCommandStep1 NewFailCommand(long jobKey) - { - ClientWasUsed = true; - return Client.NewFailCommand(jobKey); - } - - public IThrowErrorCommandStep1 NewThrowErrorCommand(long jobKey) - { - ClientWasUsed = true; - return Client.NewThrowErrorCommand(jobKey); - } - - public void Reset() - { - ClientWasUsed = false; - } - - public ICompleteJobCommandStep1 NewCompleteJobCommand(IJob activatedJob) - { - ClientWasUsed = true; - return Client.NewCompleteJobCommand(activatedJob); - } + ClientWasUsed = true; + return Client.NewCompleteJobCommand(activatedJob); } } \ No newline at end of file diff --git a/Client/Impl/Worker/JobWorker.cs b/Client/Impl/Worker/JobWorker.cs index c005283d..c67805f9 100644 --- a/Client/Impl/Worker/JobWorker.cs +++ b/Client/Impl/Worker/JobWorker.cs @@ -14,252 +14,242 @@ // limitations under the License. using System; -using System.ComponentModel.Design; using System.Threading; using System.Threading.Tasks; using System.Threading.Tasks.Dataflow; using GatewayProtocol; using Grpc.Core; using Microsoft.Extensions.Logging; -using Zeebe.Client.Api.Misc; using Zeebe.Client.Api.Responses; using Zeebe.Client.Api.Worker; using Zeebe.Client.Impl.Commands; -namespace Zeebe.Client.Impl.Worker +namespace Zeebe.Client.Impl.Worker; + +public sealed class JobWorker : IJobWorker { - public class JobWorker : IJobWorker + private const string JobFailMessage = + "Job worker '{0}' tried to handle job of type '{1}', but exception occured '{2}'"; + + private readonly CancellationTokenSource source; + private readonly ILogger logger; + private readonly JobWorkerBuilder jobWorkerBuilder; + private readonly ActivateJobsRequest activateJobsRequest; + private readonly JobActivator jobActivator; + private readonly int maxJobsActive; + private readonly AsyncJobHandler jobHandler; + private readonly bool autoCompletion; + private readonly TimeSpan pollInterval; + private readonly double thresholdJobsActivation; + + private int currentJobsActive; + private volatile bool isRunning; + + internal JobWorker(JobWorkerBuilder builder) { - private const string JobFailMessage = - "Job worker '{0}' tried to handle job of type '{1}', but exception occured '{2}'"; - - private readonly CancellationTokenSource source; - private readonly ILogger logger; - private readonly JobWorkerBuilder jobWorkerBuilder; - private readonly ActivateJobsRequest activateJobsRequest; - private readonly JobActivator jobActivator; - private readonly int maxJobsActive; - private readonly AsyncJobHandler jobHandler; - private readonly bool autoCompletion; - private readonly TimeSpan pollInterval; - private readonly double thresholdJobsActivation; - - private int currentJobsActive; - private volatile bool isRunning; + jobWorkerBuilder = builder; + source = new CancellationTokenSource(); + logger = builder.LoggerFactory?.CreateLogger(); + jobHandler = jobWorkerBuilder.Handler(); + autoCompletion = builder.AutoCompletionEnabled(); + pollInterval = jobWorkerBuilder.PollInterval(); + activateJobsRequest = jobWorkerBuilder.Request; + jobActivator = jobWorkerBuilder.Activator; + maxJobsActive = jobWorkerBuilder.Request.MaxJobsToActivate; + thresholdJobsActivation = maxJobsActive * 0.6; + } - internal JobWorker(JobWorkerBuilder builder) - { - this.jobWorkerBuilder = builder; - this.source = new CancellationTokenSource(); - this.logger = builder.LoggerFactory?.CreateLogger(); - this.jobHandler = jobWorkerBuilder.Handler(); - this.autoCompletion = builder.AutoCompletionEnabled(); - this.pollInterval = jobWorkerBuilder.PollInterval(); - this.activateJobsRequest = jobWorkerBuilder.Request; - jobActivator = jobWorkerBuilder.Activator; - this.maxJobsActive = jobWorkerBuilder.Request.MaxJobsToActivate; - this.thresholdJobsActivation = maxJobsActive * 0.6; - } + /// + public void Dispose() + { + source.Cancel(); + // delay disposing, since poll and handler take some time to close + Task.Delay(TimeSpan.FromMilliseconds(pollInterval.TotalMilliseconds * 2)) + .ContinueWith(t => + { + logger?.LogError("Dispose source"); + source.Dispose(); + }); + isRunning = false; + } - /// - public void Dispose() - { - source.Cancel(); - // delay disposing, since poll and handler take some time to close - Task.Delay(TimeSpan.FromMilliseconds(pollInterval.TotalMilliseconds * 2)) - .ContinueWith(t => - { - logger?.LogError("Dispose source"); - source.Dispose(); - }); - isRunning = false; - } + /// + public bool IsOpen() + { + return isRunning; + } - /// - public bool IsOpen() - { - return isRunning; - } + /// + public bool IsClosed() + { + return !isRunning; + } - /// - public bool IsClosed() - { - return !isRunning; - } + /// + /// Opens the configured JobWorker to activate jobs in the given poll interval + /// and handle with the given handler. + /// + internal void Open() + { + isRunning = true; + var cancellationToken = source.Token; + var bufferOptions = CreateBufferOptions(cancellationToken); + var executionOptions = CreateExecutionOptions(cancellationToken); + + var input = new BufferBlock(bufferOptions); + var transformer = new TransformBlock(async activatedJob => await HandleActivatedJob(activatedJob, cancellationToken), + executionOptions); + var output = new ActionBlock(activatedJob => + { + Interlocked.Decrement(ref currentJobsActive); + }, + executionOptions); + + input.LinkTo(transformer); + transformer.LinkTo(output); + + // Start polling + Task.Run(async () => await PollJobs(input, cancellationToken), + cancellationToken).ContinueWith( + t => logger?.LogError(t.Exception, "Job polling failed."), + TaskContinuationOptions.OnlyOnFaulted); + + logger?.LogDebug( + "Job worker ({worker}) for job type {type} has been opened.", + activateJobsRequest.Worker, + activateJobsRequest.Type); + } - /// - /// Opens the configured JobWorker to activate jobs in the given poll interval - /// and handle with the given handler. - /// - internal void Open() + private ExecutionDataflowBlockOptions CreateExecutionOptions(CancellationToken cancellationToken) + { + return new ExecutionDataflowBlockOptions { - isRunning = true; - var cancellationToken = source.Token; - var bufferOptions = CreateBufferOptions(cancellationToken); - var executionOptions = CreateExecutionOptions(cancellationToken); - - var input = new BufferBlock(bufferOptions); - var transformer = new TransformBlock(async activatedJob => await HandleActivatedJob(activatedJob, cancellationToken), - executionOptions); - var output = new ActionBlock(activatedJob => - { - Interlocked.Decrement(ref currentJobsActive); - }, - executionOptions); - - input.LinkTo(transformer); - transformer.LinkTo(output); - - // Start polling - Task.Run(async () => await PollJobs(input, cancellationToken), - cancellationToken).ContinueWith( - t => logger?.LogError(t.Exception, "Job polling failed."), - TaskContinuationOptions.OnlyOnFaulted); - - logger?.LogDebug( - "Job worker ({worker}) for job type {type} has been opened.", - activateJobsRequest.Worker, - activateJobsRequest.Type); - } + MaxDegreeOfParallelism = jobWorkerBuilder.ThreadCount, + CancellationToken = cancellationToken, + EnsureOrdered = false + }; + } - private ExecutionDataflowBlockOptions CreateExecutionOptions(CancellationToken cancellationToken) + private static DataflowBlockOptions CreateBufferOptions(CancellationToken cancellationToken) + { + return new DataflowBlockOptions { - return new ExecutionDataflowBlockOptions - { - MaxDegreeOfParallelism = jobWorkerBuilder.ThreadCount, - CancellationToken = cancellationToken, - EnsureOrdered = false - }; - } + CancellationToken = cancellationToken, + EnsureOrdered = false + }; + } - private static DataflowBlockOptions CreateBufferOptions(CancellationToken cancellationToken) + private async Task PollJobs(ITargetBlock input, CancellationToken cancellationToken) + { + while (!source.IsCancellationRequested) { - return new DataflowBlockOptions + var currentJobs = Thread.VolatileRead(ref currentJobsActive); + if (currentJobs < thresholdJobsActivation) { - CancellationToken = cancellationToken, - EnsureOrdered = false - }; - } + var jobCount = maxJobsActive - currentJobs; + activateJobsRequest.MaxJobsToActivate = jobCount; - private async Task PollJobs(ITargetBlock input, CancellationToken cancellationToken) - { - while (!source.IsCancellationRequested) - { - var currentJobs = Thread.VolatileRead(ref currentJobsActive); - if (currentJobs < thresholdJobsActivation) + try { - var jobCount = maxJobsActive - currentJobs; - activateJobsRequest.MaxJobsToActivate = jobCount; - - try - { - await jobActivator.SendActivateRequest(activateJobsRequest, - async jobsResponse => await HandleActivationResponse(input, jobsResponse, jobCount), - null, - cancellationToken); - } - catch (RpcException rpcException) - { - LogRpcException(rpcException); - await Task.Delay(pollInterval, cancellationToken); - } + await jobActivator.SendActivateRequest(activateJobsRequest, + async jobsResponse => await HandleActivationResponse(input, jobsResponse, jobCount), + null, + cancellationToken); } - else + catch (RpcException rpcException) { + LogRpcException(rpcException); await Task.Delay(pollInterval, cancellationToken); } } - } - - private async Task HandleActivationResponse(ITargetBlock input, IActivateJobsResponse response, int jobCount) - { - logger?.LogDebug( - "Job worker ({worker}) activated {activatedCount} of {requestCount} successfully.", - activateJobsRequest.Worker, - response.Jobs.Count, - jobCount); - - foreach (var job in response.Jobs) + else { - await input.SendAsync(job); - Interlocked.Increment(ref currentJobsActive); + await Task.Delay(pollInterval, cancellationToken); } } + } + + private async Task HandleActivationResponse(ITargetBlock input, IActivateJobsResponse response, int jobCount) + { + logger?.LogDebug( + "Job worker ({worker}) activated {activatedCount} of {requestCount} successfully.", + activateJobsRequest.Worker, + response.Jobs.Count, + jobCount); - private async Task HandleActivatedJob(IJob activatedJob, CancellationToken cancellationToken) + foreach (var job in response.Jobs) { - var jobClient = JobClientWrapper.Wrap(jobWorkerBuilder.JobClient); + await input.SendAsync(job); + Interlocked.Increment(ref currentJobsActive); + } + } - try - { - await jobHandler(jobClient, activatedJob); - await TryToAutoCompleteJob(jobClient, activatedJob, cancellationToken); - } - catch (Exception exception) - { - await FailActivatedJob(jobClient, activatedJob, cancellationToken, exception); - } - finally - { - jobClient.Reset(); - } + private async Task HandleActivatedJob(IJob activatedJob, CancellationToken cancellationToken) + { + var jobClient = JobClientWrapper.Wrap(jobWorkerBuilder.JobClient); - return activatedJob; + try + { + await jobHandler(jobClient, activatedJob); + await TryToAutoCompleteJob(jobClient, activatedJob, cancellationToken); } - - private void LogRpcException(RpcException rpcException) + catch (Exception exception) { - LogLevel logLevel; - switch (rpcException.StatusCode) - { - case StatusCode.DeadlineExceeded: - case StatusCode.Cancelled: - case StatusCode.ResourceExhausted: - logLevel = LogLevel.Trace; - break; - default: - logLevel = LogLevel.Error; - break; - } - - logger?.Log(logLevel, rpcException, "Unexpected RpcException on polling new jobs."); + await FailActivatedJob(jobClient, activatedJob, cancellationToken, exception); } - - private async Task TryToAutoCompleteJob(JobClientWrapper jobClient, IJob activatedJob, - CancellationToken cancellationToken) + finally { - if (!jobClient.ClientWasUsed && autoCompletion) - { - logger?.LogDebug( - "Job worker ({worker}) will auto complete job with key '{key}'", - activateJobsRequest.Worker, - activatedJob.Key); - await jobClient.NewCompleteJobCommand(activatedJob) - .Send(cancellationToken); - } + jobClient.Reset(); } - private Task FailActivatedJob(JobClientWrapper jobClient, IJob activatedJob, CancellationToken cancellationToken, Exception exception) + return activatedJob; + } + + private void LogRpcException(RpcException rpcException) + { + LogLevel logLevel = rpcException.StatusCode switch { - var errorMessage = string.Format( - JobFailMessage, - activatedJob.Worker, - activatedJob.Type, - exception.Message); - logger?.LogError(exception, errorMessage); + StatusCode.DeadlineExceeded or StatusCode.Cancelled or StatusCode.ResourceExhausted => LogLevel.Trace, + _ => LogLevel.Error + }; - return jobClient.NewFailCommand(activatedJob.Key) - .Retries(activatedJob.Retries - 1) - .ErrorMessage(errorMessage) - .Send(cancellationToken) - .ContinueWith( - task => - { - if (task.IsFaulted) - { - logger?.LogError("Problem on failing job occured.", task.Exception); - } - }, cancellationToken); + logger?.Log(logLevel, rpcException, "Unexpected RpcException on polling new jobs."); + } + + private async Task TryToAutoCompleteJob(JobClientWrapper jobClient, IJob activatedJob, + CancellationToken cancellationToken) + { + if (!jobClient.ClientWasUsed && autoCompletion) + { + logger?.LogDebug( + "Job worker ({worker}) will auto complete job with key '{key}'", + activateJobsRequest.Worker, + activatedJob.Key); + await jobClient.NewCompleteJobCommand(activatedJob) + .Send(cancellationToken); } } + + private Task FailActivatedJob(JobClientWrapper jobClient, IJob activatedJob, CancellationToken cancellationToken, Exception exception) + { + var errorMessage = string.Format( + JobFailMessage, + activatedJob.Worker, + activatedJob.Type, + exception.Message); + logger?.LogError(exception, errorMessage); + + return jobClient.NewFailCommand(activatedJob.Key) + .Retries(activatedJob.Retries - 1) + .ErrorMessage(errorMessage) + .Send(cancellationToken) + .ContinueWith( + task => + { + if (task.IsFaulted) + { + logger?.LogError("Problem on failing job occured.", task.Exception); + } + }, cancellationToken); + } } \ No newline at end of file diff --git a/Client/Impl/Worker/JobWorkerBuilder.cs b/Client/Impl/Worker/JobWorkerBuilder.cs index fe0996de..b32b5383 100644 --- a/Client/Impl/Worker/JobWorkerBuilder.cs +++ b/Client/Impl/Worker/JobWorkerBuilder.cs @@ -19,145 +19,136 @@ using System.Threading.Tasks; using GatewayProtocol; using Microsoft.Extensions.Logging; -using Zeebe.Client.Api.Misc; using Zeebe.Client.Api.Worker; using Zeebe.Client.Impl.Commands; -namespace Zeebe.Client.Impl.Worker +namespace Zeebe.Client.Impl.Worker; + +public class JobWorkerBuilder( + IZeebeClient zeebeClient, + Gateway.GatewayClient gatewayClient, + ILoggerFactory loggerFactory = null) + : IJobWorkerBuilderStep1, IJobWorkerBuilderStep2, IJobWorkerBuilderStep3 { - public class JobWorkerBuilder : IJobWorkerBuilderStep1, IJobWorkerBuilderStep2, IJobWorkerBuilderStep3 - { - private TimeSpan pollInterval; - private AsyncJobHandler asyncJobHandler; - private bool autoCompletion; - internal JobActivator Activator { get; } - internal ActivateJobsRequest Request { get; } - internal byte ThreadCount { get; set; } - internal ILoggerFactory LoggerFactory { get; } - internal IJobClient JobClient { get; } - - public JobWorkerBuilder(IZeebeClient zeebeClient, - Gateway.GatewayClient gatewayClient, - ILoggerFactory loggerFactory = null) - { - LoggerFactory = loggerFactory; - Activator = new JobActivator(gatewayClient); - Request = new ActivateJobsRequest(); - JobClient = zeebeClient; - ThreadCount = 1; - } + private TimeSpan pollInterval; + private AsyncJobHandler asyncJobHandler; + private bool autoCompletion; + internal JobActivator Activator { get; } = new (gatewayClient); + internal ActivateJobsRequest Request { get; } = new (); + internal byte ThreadCount { get; set; } = 1; + internal ILoggerFactory LoggerFactory { get; } = loggerFactory; + internal IJobClient JobClient { get; } = zeebeClient; + + public IJobWorkerBuilderStep2 JobType(string type) + { + Request.Type = type; + return this; + } - public IJobWorkerBuilderStep2 JobType(string type) - { - Request.Type = type; - return this; - } + public IJobWorkerBuilderStep3 Handler(JobHandler handler) + { + asyncJobHandler = (c, j) => Task.Run(() => handler.Invoke(c, j)); + return this; + } - public IJobWorkerBuilderStep3 Handler(JobHandler handler) - { - this.asyncJobHandler = (c, j) => Task.Run(() => handler.Invoke(c, j)); - return this; - } + public IJobWorkerBuilderStep3 Handler(AsyncJobHandler handler) + { + asyncJobHandler = handler; + return this; + } - public IJobWorkerBuilderStep3 Handler(AsyncJobHandler handler) - { - this.asyncJobHandler = handler; - return this; - } + public IJobWorkerBuilderStep3 TenantIds(IList tenantIds) + { + Request.TenantIds.AddRange(tenantIds); + return this; + } - public IJobWorkerBuilderStep3 TenantIds(IList tenantIds) - { - Request.TenantIds.AddRange(tenantIds); - return this; - } + public IJobWorkerBuilderStep3 TenantIds(params string[] tenantIds) + { + return TenantIds(tenantIds.ToList()); + } - public IJobWorkerBuilderStep3 TenantIds(params string[] tenantIds) - { - return TenantIds(tenantIds.ToList()); - } + internal AsyncJobHandler Handler() + { + return asyncJobHandler; + } - internal AsyncJobHandler Handler() - { - return asyncJobHandler; - } + public IJobWorkerBuilderStep3 Timeout(TimeSpan timeout) + { + Request.Timeout = (long) timeout.TotalMilliseconds; + return this; + } - public IJobWorkerBuilderStep3 Timeout(TimeSpan timeout) - { - Request.Timeout = (long) timeout.TotalMilliseconds; - return this; - } + public IJobWorkerBuilderStep3 Name(string workerName) + { + Request.Worker = workerName; + return this; + } - public IJobWorkerBuilderStep3 Name(string workerName) - { - Request.Worker = workerName; - return this; - } + public IJobWorkerBuilderStep3 MaxJobsActive(int maxJobsActive) + { + Request.MaxJobsToActivate = maxJobsActive; + return this; + } - public IJobWorkerBuilderStep3 MaxJobsActive(int maxJobsActive) - { - Request.MaxJobsToActivate = maxJobsActive; - return this; - } + public IJobWorkerBuilderStep3 FetchVariables(IList fetchVariables) + { + Request.FetchVariable.AddRange(fetchVariables); + return this; + } - public IJobWorkerBuilderStep3 FetchVariables(IList fetchVariables) - { - Request.FetchVariable.AddRange(fetchVariables); - return this; - } + public IJobWorkerBuilderStep3 FetchVariables(params string[] fetchVariables) + { + Request.FetchVariable.AddRange(fetchVariables); + return this; + } - public IJobWorkerBuilderStep3 FetchVariables(params string[] fetchVariables) - { - Request.FetchVariable.AddRange(fetchVariables); - return this; - } + public IJobWorkerBuilderStep3 PollInterval(TimeSpan pollInterval) + { + this.pollInterval = pollInterval; + return this; + } - public IJobWorkerBuilderStep3 PollInterval(TimeSpan pollInterval) - { - this.pollInterval = pollInterval; - return this; - } + internal TimeSpan PollInterval() + { + return pollInterval; + } - internal TimeSpan PollInterval() - { - return pollInterval; - } + public IJobWorkerBuilderStep3 PollingTimeout(TimeSpan pollingTimeout) + { + Request.RequestTimeout = (long) pollingTimeout.TotalMilliseconds; + return this; + } - public IJobWorkerBuilderStep3 PollingTimeout(TimeSpan pollingTimeout) - { - Request.RequestTimeout = (long) pollingTimeout.TotalMilliseconds; - return this; - } + public IJobWorkerBuilderStep3 AutoCompletion() + { + autoCompletion = true; + return this; + } - public IJobWorkerBuilderStep3 AutoCompletion() + public IJobWorkerBuilderStep3 HandlerThreads(byte threadCount) + { + if (threadCount <= 0) { - autoCompletion = true; - return this; + var errorMsg = $"Expected an handler thread count larger then zero, but got {threadCount}."; + throw new ArgumentOutOfRangeException(errorMsg); } - public IJobWorkerBuilderStep3 HandlerThreads(byte threadCount) - { - if (threadCount <= 0) - { - var errorMsg = $"Expected an handler thread count larger then zero, but got {threadCount}."; - throw new ArgumentOutOfRangeException(errorMsg); - } - - this.ThreadCount = threadCount; - return this; - } + ThreadCount = threadCount; + return this; + } - internal bool AutoCompletionEnabled() - { - return autoCompletion; - } + internal bool AutoCompletionEnabled() + { + return autoCompletion; + } - public IJobWorker Open() - { - var worker = new JobWorker(this); + public IJobWorker Open() + { + var worker = new JobWorker(this); - worker.Open(); + worker.Open(); - return worker; - } + return worker; } -} +} \ No newline at end of file diff --git a/Client/Impl/proto/ClosedGatewayClient.cs b/Client/Impl/proto/ClosedGatewayClient.cs index 1ee18f27..482b32e9 100644 --- a/Client/Impl/proto/ClosedGatewayClient.cs +++ b/Client/Impl/proto/ClosedGatewayClient.cs @@ -2,403 +2,402 @@ using System.Threading; using Grpc.Core; -namespace GatewayProtocol +namespace GatewayProtocol; + +public class ClosedGatewayClient : Gateway.GatewayClient { - public class ClosedGatewayClient : Gateway.GatewayClient - { - private const string ZeebeClientWasAlreadyDisposed = "ZeebeClient was already disposed."; - - public override AsyncServerStreamingCall ActivateJobs(ActivateJobsRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncServerStreamingCall ActivateJobs(ActivateJobsRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override CancelProcessInstanceResponse CancelProcessInstance(CancelProcessInstanceRequest request, Metadata headers = null, - DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override CancelProcessInstanceResponse CancelProcessInstance(CancelProcessInstanceRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall CancelProcessInstanceAsync(CancelProcessInstanceRequest request, Metadata headers = null, - DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall CancelProcessInstanceAsync(CancelProcessInstanceRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override CompleteJobResponse CompleteJob(CompleteJobRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override CompleteJobResponse CompleteJob(CompleteJobRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall CompleteJobAsync(CompleteJobRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall CompleteJobAsync(CompleteJobRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override CreateProcessInstanceResponse CreateProcessInstance(CreateProcessInstanceRequest request, Metadata headers = null, - DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override CreateProcessInstanceResponse CreateProcessInstance(CreateProcessInstanceRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall CreateProcessInstanceAsync(CreateProcessInstanceRequest request, Metadata headers = null, - DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall CreateProcessInstanceAsync(CreateProcessInstanceRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override DeployProcessResponse DeployProcess(DeployProcessRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override DeployProcessResponse DeployProcess(DeployProcessRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall DeployProcessAsync(DeployProcessRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall DeployProcessAsync(DeployProcessRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override FailJobResponse FailJob(FailJobRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override FailJobResponse FailJob(FailJobRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall FailJobAsync(FailJobRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall FailJobAsync(FailJobRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override PublishMessageResponse PublishMessage(PublishMessageRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override PublishMessageResponse PublishMessage(PublishMessageRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall PublishMessageAsync(PublishMessageRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall PublishMessageAsync(PublishMessageRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override ResolveIncidentResponse ResolveIncident(ResolveIncidentRequest request, Metadata headers = null, - DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override ResolveIncidentResponse ResolveIncident(ResolveIncidentRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall ResolveIncidentAsync(ResolveIncidentRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall ResolveIncidentAsync(ResolveIncidentRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override SetVariablesResponse SetVariables(SetVariablesRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override SetVariablesResponse SetVariables(SetVariablesRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall SetVariablesAsync(SetVariablesRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall SetVariablesAsync(SetVariablesRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override TopologyResponse Topology(TopologyRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override TopologyResponse Topology(TopologyRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall TopologyAsync(TopologyRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall TopologyAsync(TopologyRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override UpdateJobRetriesResponse UpdateJobRetries(UpdateJobRetriesRequest request, Metadata headers = null, - DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override UpdateJobRetriesResponse UpdateJobRetries(UpdateJobRetriesRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall UpdateJobRetriesAsync(UpdateJobRetriesRequest request, Metadata headers = null, - DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall UpdateJobRetriesAsync(UpdateJobRetriesRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - protected override Gateway.GatewayClient NewInstance(ClientBaseConfiguration configuration) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override CreateProcessInstanceWithResultResponse CreateProcessInstanceWithResult(CreateProcessInstanceWithResultRequest request, - Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override CreateProcessInstanceWithResultResponse CreateProcessInstanceWithResult(CreateProcessInstanceWithResultRequest request, - CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall CreateProcessInstanceWithResultAsync(CreateProcessInstanceWithResultRequest request, - Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall CreateProcessInstanceWithResultAsync(CreateProcessInstanceWithResultRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override EvaluateDecisionResponse EvaluateDecision(EvaluateDecisionRequest request, Metadata headers = null, - DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override EvaluateDecisionResponse EvaluateDecision(EvaluateDecisionRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall EvaluateDecisionAsync(EvaluateDecisionRequest request, Metadata headers = null, - DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall EvaluateDecisionAsync(EvaluateDecisionRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override DeployResourceResponse DeployResource(DeployResourceRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override DeployResourceResponse DeployResource(DeployResourceRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall DeployResourceAsync(DeployResourceRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall DeployResourceAsync(DeployResourceRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override ThrowErrorResponse ThrowError(ThrowErrorRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override ThrowErrorResponse ThrowError(ThrowErrorRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall ThrowErrorAsync(ThrowErrorRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall ThrowErrorAsync(ThrowErrorRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override ModifyProcessInstanceResponse ModifyProcessInstance(ModifyProcessInstanceRequest request, Metadata headers = null, - DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override ModifyProcessInstanceResponse ModifyProcessInstance(ModifyProcessInstanceRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall ModifyProcessInstanceAsync(ModifyProcessInstanceRequest request, Metadata headers = null, - DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall ModifyProcessInstanceAsync(ModifyProcessInstanceRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override DeleteResourceResponse DeleteResource(DeleteResourceRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override DeleteResourceResponse DeleteResource(DeleteResourceRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall DeleteResourceAsync(DeleteResourceRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall DeleteResourceAsync(DeleteResourceRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override BroadcastSignalResponse BroadcastSignal(BroadcastSignalRequest request, Metadata headers = null, - DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override BroadcastSignalResponse BroadcastSignal(BroadcastSignalRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall BroadcastSignalAsync(BroadcastSignalRequest request, Metadata headers = null, DateTime? deadline = null, - CancellationToken cancellationToken = default(CancellationToken)) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - - public override AsyncUnaryCall BroadcastSignalAsync(BroadcastSignalRequest request, CallOptions options) - { - throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); - } - } -} + private const string ZeebeClientWasAlreadyDisposed = "ZeebeClient was already disposed."; + + public override AsyncServerStreamingCall ActivateJobs(ActivateJobsRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncServerStreamingCall ActivateJobs(ActivateJobsRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override CancelProcessInstanceResponse CancelProcessInstance(CancelProcessInstanceRequest request, Metadata headers = null, + DateTime? deadline = null, CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override CancelProcessInstanceResponse CancelProcessInstance(CancelProcessInstanceRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall CancelProcessInstanceAsync(CancelProcessInstanceRequest request, Metadata headers = null, + DateTime? deadline = null, CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall CancelProcessInstanceAsync(CancelProcessInstanceRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override CompleteJobResponse CompleteJob(CompleteJobRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override CompleteJobResponse CompleteJob(CompleteJobRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall CompleteJobAsync(CompleteJobRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall CompleteJobAsync(CompleteJobRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override CreateProcessInstanceResponse CreateProcessInstance(CreateProcessInstanceRequest request, Metadata headers = null, + DateTime? deadline = null, CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override CreateProcessInstanceResponse CreateProcessInstance(CreateProcessInstanceRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall CreateProcessInstanceAsync(CreateProcessInstanceRequest request, Metadata headers = null, + DateTime? deadline = null, CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall CreateProcessInstanceAsync(CreateProcessInstanceRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override DeployProcessResponse DeployProcess(DeployProcessRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override DeployProcessResponse DeployProcess(DeployProcessRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall DeployProcessAsync(DeployProcessRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall DeployProcessAsync(DeployProcessRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override FailJobResponse FailJob(FailJobRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override FailJobResponse FailJob(FailJobRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall FailJobAsync(FailJobRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall FailJobAsync(FailJobRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override PublishMessageResponse PublishMessage(PublishMessageRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override PublishMessageResponse PublishMessage(PublishMessageRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall PublishMessageAsync(PublishMessageRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall PublishMessageAsync(PublishMessageRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override ResolveIncidentResponse ResolveIncident(ResolveIncidentRequest request, Metadata headers = null, + DateTime? deadline = null, CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override ResolveIncidentResponse ResolveIncident(ResolveIncidentRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall ResolveIncidentAsync(ResolveIncidentRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall ResolveIncidentAsync(ResolveIncidentRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override SetVariablesResponse SetVariables(SetVariablesRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override SetVariablesResponse SetVariables(SetVariablesRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall SetVariablesAsync(SetVariablesRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall SetVariablesAsync(SetVariablesRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override TopologyResponse Topology(TopologyRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override TopologyResponse Topology(TopologyRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall TopologyAsync(TopologyRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall TopologyAsync(TopologyRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override UpdateJobRetriesResponse UpdateJobRetries(UpdateJobRetriesRequest request, Metadata headers = null, + DateTime? deadline = null, CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override UpdateJobRetriesResponse UpdateJobRetries(UpdateJobRetriesRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall UpdateJobRetriesAsync(UpdateJobRetriesRequest request, Metadata headers = null, + DateTime? deadline = null, CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall UpdateJobRetriesAsync(UpdateJobRetriesRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + protected override Gateway.GatewayClient NewInstance(ClientBaseConfiguration configuration) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override CreateProcessInstanceWithResultResponse CreateProcessInstanceWithResult(CreateProcessInstanceWithResultRequest request, + Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override CreateProcessInstanceWithResultResponse CreateProcessInstanceWithResult(CreateProcessInstanceWithResultRequest request, + CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall CreateProcessInstanceWithResultAsync(CreateProcessInstanceWithResultRequest request, + Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall CreateProcessInstanceWithResultAsync(CreateProcessInstanceWithResultRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override EvaluateDecisionResponse EvaluateDecision(EvaluateDecisionRequest request, Metadata headers = null, + DateTime? deadline = null, CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override EvaluateDecisionResponse EvaluateDecision(EvaluateDecisionRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall EvaluateDecisionAsync(EvaluateDecisionRequest request, Metadata headers = null, + DateTime? deadline = null, CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall EvaluateDecisionAsync(EvaluateDecisionRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override DeployResourceResponse DeployResource(DeployResourceRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override DeployResourceResponse DeployResource(DeployResourceRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall DeployResourceAsync(DeployResourceRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall DeployResourceAsync(DeployResourceRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override ThrowErrorResponse ThrowError(ThrowErrorRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override ThrowErrorResponse ThrowError(ThrowErrorRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall ThrowErrorAsync(ThrowErrorRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall ThrowErrorAsync(ThrowErrorRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override ModifyProcessInstanceResponse ModifyProcessInstance(ModifyProcessInstanceRequest request, Metadata headers = null, + DateTime? deadline = null, CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override ModifyProcessInstanceResponse ModifyProcessInstance(ModifyProcessInstanceRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall ModifyProcessInstanceAsync(ModifyProcessInstanceRequest request, Metadata headers = null, + DateTime? deadline = null, CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall ModifyProcessInstanceAsync(ModifyProcessInstanceRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override DeleteResourceResponse DeleteResource(DeleteResourceRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override DeleteResourceResponse DeleteResource(DeleteResourceRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall DeleteResourceAsync(DeleteResourceRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall DeleteResourceAsync(DeleteResourceRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override BroadcastSignalResponse BroadcastSignal(BroadcastSignalRequest request, Metadata headers = null, + DateTime? deadline = null, CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override BroadcastSignalResponse BroadcastSignal(BroadcastSignalRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall BroadcastSignalAsync(BroadcastSignalRequest request, Metadata headers = null, DateTime? deadline = null, + CancellationToken cancellationToken = default) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } + + public override AsyncUnaryCall BroadcastSignalAsync(BroadcastSignalRequest request, CallOptions options) + { + throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed); + } +} \ No newline at end of file diff --git a/Client/ServiceCollectionExtensions.cs b/Client/ServiceCollectionExtensions.cs index 8d2f83ab..b84a2853 100644 --- a/Client/ServiceCollectionExtensions.cs +++ b/Client/ServiceCollectionExtensions.cs @@ -2,28 +2,27 @@ using Microsoft.Extensions.Logging; using Zeebe.Client.Impl.Builder; -namespace Zeebe.Client +namespace Zeebe.Client; + +public static class ServiceCollectionExtensions { - public static class ServiceCollectionExtensions + /// + /// Adds the Zeebe builders to the IServiceCollection + /// + /// the collection where the zeebe services are appended + /// the service collection + public static IServiceCollection AddZeebeBuilders(this IServiceCollection services) { - /// - /// Adds the Zeebe builders to the IServiceCollection - /// - /// the collection where the zeebe services are appended - /// the service collection - public static IServiceCollection AddZeebeBuilders(this IServiceCollection services) + services.AddTransient(serviceProvider => + { + var loggerFactory = serviceProvider.GetService(); + return ZeebeClient.Builder().UseLoggerFactory(loggerFactory); + }); + services.AddTransient(serviceProvider => { - services.AddTransient(serviceProvider => - { - var loggerFactory = serviceProvider.GetService(); - return ZeebeClient.Builder().UseLoggerFactory(loggerFactory); - }); - services.AddTransient(serviceProvider => - { - var loggerFactory = serviceProvider.GetService(); - return CamundaCloudTokenProvider.Builder().UseLoggerFactory(loggerFactory); - }); - return services; - } + var loggerFactory = serviceProvider.GetService(); + return CamundaCloudTokenProvider.Builder().UseLoggerFactory(loggerFactory); + }); + return services; } -} +} \ No newline at end of file