Exemplo n.º 1
0
        public async Task <FunctionResult> TryExecuteAsync(TriggeredFunctionData input, CancellationToken cancellationToken)
        {
            var context = new FunctionInstanceFactoryContext <TTriggerValue>()
            {
                TriggerValue   = (TTriggerValue)input.TriggerValue,
                ParentId       = input.ParentId,
                TriggerDetails = input.TriggerDetails
            };

            if (input.InvokeHandler != null)
            {
                context.InvokeHandler = async next =>
                {
                    await input.InvokeHandler(next);

                    // NOTE: The InvokeHandler code path currently does not support flowing the return
                    // value back to the trigger.
                    return(null);
                };
            }

            IFunctionInstance instance  = _instanceFactory.Create(context);
            IDelayedException exception = await _executor.TryExecuteAsync(instance, cancellationToken);

            FunctionResult result = exception != null ?
                                    new FunctionResult(exception.Exception)
                : new FunctionResult(true);

            return(result);
        }