Ejemplo n.º 1
0
        public async Task ShouldUseActivatedJobToComplete()
        {
            // given
            const string Variables = "{\"foo\":23}";
            const int    JobKey    = 255;

            var grpcActivatedJob = new ActivatedJob();

            grpcActivatedJob.Key        = JobKey;
            grpcActivatedJob.JobHeaders = new JobHeaders();
            var activatedJob    = new Impl.Responses.ActivatedJob(grpcActivatedJob);
            var expectedRequest = new CompleteJobRequest
            {
                JobKey    = JobKey,
                Variables = Variables
            };

            // when
            await ZeebeClient.NewCompleteJobCommand(activatedJob).Variables(Variables).Send();

            // then
            var actualRequest = TestService.Requests[0];

            Assert.AreEqual(expectedRequest, actualRequest);
        }
Ejemplo n.º 2
0
 public CompleteJobCommand(GatewayClient client, long jobKey)
 {
     gatewayClient = client;
     request       = new CompleteJobRequest
     {
         JobKey = jobKey
     };
 }
 public CompleteJobCommand(GatewayClient client, IAsyncRetryStrategy asyncRetryStrategy, long jobKey)
 {
     gatewayClient = client;
     request       = new CompleteJobRequest
     {
         JobKey = jobKey
     };
     this.asyncRetryStrategy = asyncRetryStrategy;
 }
Ejemplo n.º 4
0
        public void ShouldUseAutoCompleteWithWorker()
        {
            // given
            var expectedRequest = new ActivateJobsRequest
            {
                Timeout           = 5_000L,
                MaxJobsToActivate = 3,
                Type   = "foo",
                Worker = "jobWorker"
            };

            var expectedCompleteRequest = new CompleteJobRequest();

            TestService.AddRequestHandler(typeof(ActivateJobsRequest),
                                          request => CreateExpectedResponse());

            // when
            using (var jobWorker = ZeebeClient.NewWorker()
                                   .JobType("foo")
                                   .Handler((jobClient, job) =>
            {
                Logger.Info("Handler has seen job '{0}'", job);
            })
                                   .AutoCompletion()
                                   .MaxJobsActive(3)
                                   .Name("jobWorker")
                                   .Timeout(5_000L)
                                   .PollInterval(TimeSpan.FromSeconds(5))
                                   .Open())
            {
                Assert.True(jobWorker.IsOpen());
                while (TestService.Requests.Count < 4)
                {
                }
            }

            // then
            var actualRequest = TestService.Requests[0];

            Assert.AreEqual(expectedRequest, actualRequest);

            var completeJobRequests = TestService.Requests.OfType <CompleteJobRequest>().Select(j => j.JobKey).ToList();

            Assert.AreEqual(3, completeJobRequests.Count);

            Assert.Contains(1, completeJobRequests);
            Assert.Contains(2, completeJobRequests);
            Assert.Contains(3, completeJobRequests);
        }
        public async Task ShouldSendRequestAsExpected()
        {
            // given
            const string Variables       = "{\"foo\":23}";
            const int    JobKey          = 255;
            var          expectedRequest = new CompleteJobRequest
            {
                JobKey    = JobKey,
                Variables = Variables
            };

            // when
            await ZeebeClient.NewCompleteJobCommand(JobKey).Variables(Variables).Send();

            // then
            var actualRequest = TestService.Requests[0];

            Assert.AreEqual(expectedRequest, actualRequest);
        }
Ejemplo n.º 6
0
 public override Task <CompleteJobResponse> CompleteJob(CompleteJobRequest request, ServerCallContext context)
 {
     return(Task.FromResult((CompleteJobResponse)HandleRequest(request, context)));
 }
Ejemplo n.º 7
0
 public override AsyncUnaryCall <CompleteJobResponse> CompleteJobAsync(CompleteJobRequest request, CallOptions options)
 {
     throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed);
 }
Ejemplo n.º 8
0
 public override AsyncUnaryCall <CompleteJobResponse> CompleteJobAsync(CompleteJobRequest request, Metadata headers = null, DateTime?deadline = null,
                                                                       CancellationToken cancellationToken          = default(CancellationToken))
 {
     throw new ObjectDisposedException(ZeebeClientWasAlreadyDisposed);
 }
        public async Task <NoContentResult> CompleteJob([FromBody] CompleteJobRequest request)
        {
            await _daprClient.InvokeBindingAsync("command", Commands.CompleteJob, request);

            return(NoContent());
        }