コード例 #1
0
        private static void Parser(RpcClients rpcClients)
        {
            if (rpcClients != null && rpcClients.Clients != null && rpcClients.Clients.Count > 0)
            {
                foreach (var cl in rpcClients.Clients)
                {
                    ClientServer s = new ClientServer()
                    {
                        RouterType = cl.RouterType,
                        ServerName = cl.ServerName,
                    };
                    List <ClientItem> cs = new List <ClientItem>();
                    foreach (var it in cl.Items)
                    {
                        if (!it.Enable)
                        {
                            logger.LogInformation($"服务{s.ServerName}的Ip={it.Ip},Port={it.Port}的服务被下线,路由将被忽略....");
                            continue;
                        }
                        cs.Add(new ClientItem
                        {
                            Ip         = it.Ip,
                            Port       = it.Port,
                            Server     = s,
                            ServerType = it.ServerType,
                            Pool       = it.Pool,
                            Enable     = it.Enable,
                            TimeOut    = it.TimeOut,
                        });
                    }

                    s.UpdateClient(cs.ToArray(), true);
                    Register(s);
                }
            }
        }