示例#1
0
        private async Task <(RegionClient client, RegionInfo info)> ResolveRegion(ICall rpc, CancellationToken token)
        {
            RegionInfo   reg    = null;
            RegionClient client = null;
            var          millisecondsTimeout = 60000;
            var          oldTime             = DateTime.Now;

            reg    = GetInfoFromCache(rpc.Table, rpc.Key);
            client = reg?.Client;
            if (true == client?.IsInvalid)
            {
                _cache.ClientDown(reg);
                client = null;
            }
            if (client == null)
            {
                _loadRegionQueue.Enqueue(rpc);
                await TaskEx.WaitOn(() =>
                {
                    reg    = GetInfoFromCache(rpc.Table, rpc.Key);
                    client = reg?.Client;
                    return(client == null && rpc.FindRegionRetryCount < RetryCount);
                }, 5, millisecondsTimeout);
            }
            return(client, reg);
        }