예제 #1
0
        public override async Task <string> StartNewAsync(string orchestratorFunctionName, string instanceId, object input)
        {
            if (string.IsNullOrEmpty(instanceId))
            {
                instanceId = "instance-" + _instances.Count.ToString();
            }

            if (_instances.TryGetValue(instanceId, out var existing))
            {
                await this.TerminateAsync(instanceId, null);
            }

            var context = new InMemoryOrchestrationContext(this);

            _instances.TryAdd(instanceId, context);

            context.Run(orchestratorFunctionName, input);

            return(instanceId);
        }
예제 #2
0
        public async Task <string> StartNewAsync <T>(string orchestratorFunctionName, string instanceId, T input)
        {
            if (string.IsNullOrEmpty(instanceId))
            {
                instanceId = "instance-" + _instances.Count;
            }

            if (_instances.TryGetValue(instanceId, out _))
            {
                await TerminateAsync(instanceId, null);
            }

            var context = new InMemoryOrchestrationContext(instanceId, null, this);

            _instances.TryAdd(instanceId, context);

            context.Run(orchestratorFunctionName, input);

            return(instanceId);
        }
예제 #3
0
        public async Task <TResult> CallSubOrchestratorAsync <TResult>(string functionName, string instanceId, object input)
        {
            var createdEvent = new SubOrchestrationInstanceCreatedEvent(History.Count);

            History.Add(createdEvent);

            try
            {
                var subContext = new InMemoryOrchestrationContext(instanceId, _instanceId, _client);
                await subContext.Run(functionName, input);

                var result = (TResult)subContext._output;

                History.Add(new SubOrchestrationInstanceCompletedEvent(History.Count, createdEvent.EventId,
                                                                       JsonConvert.SerializeObject(result)));

                return(result);
            }
            catch (Exception ex)
            {
                History.Add(new SubOrchestrationInstanceFailedEvent(History.Count, createdEvent.EventId, ex.Message, ex.StackTrace));
                throw;
            }
        }