Ejemplo n.º 1
0
        public static Task <bool> PerformServerActionAsync(string server, Action action)
        {
            var proxies = HAProxyGroup.GetAllProxies();
            var pairs   = proxies
                          .SelectMany(p => p.Servers
                                      .Where(s => s.Name == server)
                                      .Select(s => new ActionPair {
                Proxy = p, Server = s
            })
                                      ).ToList();

            return(PostActionsAsync(pairs, action));
        }
Ejemplo n.º 2
0
        public static bool PerformServerAction(string server, Action action)
        {
            var proxies         = HAProxyGroup.GetAllProxies();
            var matchingServers = proxies.SelectMany(p => p.Servers.Where(s => s.Name == server).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);
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
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);
        }