示例#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);
        }
示例#2
0
        private IFunctionInstance CreateFunctionInstance(CallAndOverrideMessage message)
        {
            IFunctionDefinition function = _functionLookup.Lookup(message.FunctionId);

            if (function == null)
            {
                return(null);
            }

            IDictionary <string, object> objectParameters = new Dictionary <string, object>();

            if (message.Arguments != null)
            {
                foreach (KeyValuePair <string, string> item in message.Arguments)
                {
                    objectParameters.Add(item.Key, item.Value);
                }
            }

            var context = new FunctionInstanceFactoryContext
            {
                Id              = message.Id,
                ParentId        = message.ParentId,
                ExecutionReason = message.Reason,
                Parameters      = objectParameters
            };

            return(function.InstanceFactory.Create(context));
        }
示例#3
0
        public IFunctionInstance Create(FunctionInstanceFactoryContext context)
        {
            IBindingSource bindingSource = new BindingSource(_binding, context.Parameters);

            return(new FunctionInstance(context.Id, context.ParentId, context.ExecutionReason, bindingSource, _invoker, _descriptor));
        }