Esempio n. 1
0
        public override async Task <LockNextTaskActivityWorkItemResponse> LockNextTaskActivityWorkItem(LockNextTaskActivityWorkItemRequest request, ServerCallContext context)
        {
            try
            {
                var activities = request.Activities.Select(x => new NameVersion(x.Name, x.Version)).ToArray();

                var workItem = await(request.AllActivities
                    ? _orchestrationService
                                     .LockNextTaskActivityWorkItem(request.ReceiveTimeout.ToTimeSpan(), context.CancellationToken)
                    : (_extendedOrchestrationService ?? throw DistributedWorkersNotSupported())
                                     .LockNextTaskActivityWorkItem(request.ReceiveTimeout.ToTimeSpan(), activities, context.CancellationToken));

                var response = new LockNextTaskActivityWorkItemResponse
                {
                    WorkItem = workItem == null ? null : ToGrpcWorkItem(workItem)
                };

                return(response);
            }
            catch (OperationCanceledException) when(context.CancellationToken.IsCancellationRequested)
            {
                // Avoid exceptions when clients cancel request
                return(null);
            }
        }
Esempio n. 2
0
 public async Task <TaskActivityWorkItem> LockNextTaskActivityWorkItem(TimeSpan receiveTimeout, CancellationToken cancellationToken)
 {
     return(await(_hasAllActivities
         ? _innerOrchestrationService
                  .LockNextTaskActivityWorkItem(receiveTimeout, cancellationToken)
         : (_innerExtenedOrchestrationService ?? throw DistributedWorkersNotSupported())
                  .LockNextTaskActivityWorkItem(receiveTimeout, _activities, cancellationToken)
                  ));
 }