Exemplo n.º 1
0
        public static DurableFunctionInfo Create(MapField <string, BindingInfo> bindings)
        {
            var clientBinding =
                bindings.FirstOrDefault(
                    binding => !string.IsNullOrEmpty(binding.Key) &&
                    binding.Value.Direction == BindingInfo.Types.Direction.In &&
                    DurableBindings.IsDurableClient(binding.Value.Type));

            var durableFunctionType = GetDurableFunctionType(bindings);

            return(new DurableFunctionInfo(durableFunctionType, clientBinding.Key));
        }
Exemplo n.º 2
0
        private static DurableFunctionType GetDurableFunctionType(MapField <string, BindingInfo> bindings)
        {
            var inputBindings = bindings.Where(binding => binding.Value.Direction == BindingInfo.Types.Direction.In);

            foreach (var(_, value) in inputBindings)
            {
                if (DurableBindings.IsOrchestrationTrigger(value.Type))
                {
                    return(DurableFunctionType.OrchestrationFunction);
                }

                if (DurableBindings.IsActivityTrigger(value.Type))
                {
                    return(DurableFunctionType.ActivityFunction);
                }
            }

            return(DurableFunctionType.None);
        }
Exemplo n.º 3
0
        private static void ValidateActivityFunction(string functionName, IEnumerable <AzFunctionInfo> loadedFunctions)
        {
            var functionInfo = loadedFunctions.FirstOrDefault(fi => fi.FuncName == functionName);

            if (functionInfo == null)
            {
                var message = string.Format(PowerShellWorkerStrings.FunctionNotFound, functionName);
                throw new InvalidOperationException(message);
            }

            var activityTriggerBinding = functionInfo.InputBindings.FirstOrDefault(
                entry => DurableBindings.IsActivityTrigger(entry.Value.Type) &&
                entry.Value.Direction == BindingInfo.Types.Direction.In);

            if (activityTriggerBinding.Key == null)
            {
                var message = string.Format(PowerShellWorkerStrings.FunctionDoesNotHaveProperActivityFunctionBinding, functionName);
                throw new InvalidOperationException(message);
            }
        }