Esempio n. 1
0
        public static Task <bool> PerformGroupActionAsync(string group, Action action)
        {
            var haGroup = HAProxyGroup.GetGroup(group);

            if (haGroup == null)
            {
                return(Task.FromResult(false));
            }

            var pairs = haGroup.GetProxies()
                        .SelectMany(p => p.Servers
                                    .Select(s => new ActionPair {
                Proxy = p, Server = s
            })
                                    ).ToList();

            return(PostActionsAsync(pairs, action));
        }
Esempio n. 2
0
        public static bool PerformGroupAction(string group, Action action)
        {
            var haGroup = HAProxyGroup.GetGroup(group);

            if (haGroup == null)
            {
                return(false);
            }
            var proxies         = haGroup.GetProxies();
            var matchingServers = proxies.SelectMany(p => p.Servers.Select(s => new { Proxy = p, Server = s }));

            var result = true;

            Parallel.ForEach(matchingServers, _parallelOptions, pair =>
            {
                result = result && PostAction(pair.Proxy, pair.Server, action);
            });
            return(result);
        }