protected override async Task <object> InvokeCore(object[] parameters, FunctionInvocationContext context) { // Need to wait for atleast one language worker process to be initialized before accepting invocations await DelayUntilFunctionDispatcherInitialized(); string invocationId = context.ExecutionContext.InvocationId.ToString(); // TODO: fix extensions and remove object triggerValue = TransformInput(parameters[0], context.Binder.BindingData); var triggerInput = (_bindingMetadata.Name, _bindingMetadata.DataType ?? DataType.String, triggerValue); var inputs = new[] { triggerInput }.Concat(await BindInputsAsync(context.Binder)); ScriptInvocationContext invocationContext = new ScriptInvocationContext() { FunctionMetadata = Metadata, BindingData = context.Binder.BindingData, // This has duplicates too (of type DefaultHttpRequest). Needs to be removed after verifying this can indeed be constructed by the workers from the rest of the data being passed (https://github.com/Azure/azure-functions-host/issues/4735). ExecutionContext = context.ExecutionContext, Inputs = inputs, ResultSource = new TaskCompletionSource <ScriptInvocationResult>(), AsyncExecutionContext = System.Threading.ExecutionContext.Capture(), Traceparent = Activity.Current?.Id, Attributes = Activity.Current?.Tags, // TODO: link up cancellation token to parameter descriptors CancellationToken = CancellationToken.None, Logger = context.Logger }; ScriptInvocationResult result; _logger.LogDebug($"Sending invocation id:{invocationId}"); await _functionDispatcher.InvokeAsync(invocationContext); result = await invocationContext.ResultSource.Task; await BindOutputsAsync(triggerValue, context.Binder, result); return(result.Return); }
protected override async Task <object> InvokeCore(object[] parameters, FunctionInvocationContext context) { // Need to wait for atleast one language worker process to be initialized before accepting invocations await DelayUntilFunctionDispatcherInitialized(); string invocationId = context.ExecutionContext.InvocationId.ToString(); // TODO: fix extensions and remove object triggerValue = TransformInput(parameters[0], context.Binder.BindingData); var triggerInput = (_bindingMetadata.Name, _bindingMetadata.DataType ?? DataType.String, triggerValue); var inputs = new[] { triggerInput }.Concat(await BindInputsAsync(context.Binder)); ScriptInvocationContext invocationContext = new ScriptInvocationContext() { FunctionMetadata = Metadata, BindingData = context.Binder.BindingData, ExecutionContext = context.ExecutionContext, Inputs = inputs, ResultSource = new TaskCompletionSource <ScriptInvocationResult>(), AsyncExecutionContext = System.Threading.ExecutionContext.Capture(), // TODO: link up cancellation token to parameter descriptors CancellationToken = CancellationToken.None, Logger = context.Logger }; ScriptInvocationResult result; _logger.LogDebug($"Sending invocation id:{invocationId}"); await _functionDispatcher.InvokeAsync(invocationContext); result = await invocationContext.ResultSource.Task; await BindOutputsAsync(triggerValue, context.Binder, result); return(result.Return); }