public ITransportClient CreateClient <T>(T address) where T : ServerAddress { try { _logger.Debug($"创建传输客户端: {address.Code}"); ITransportClient val = Clients.GetOrAdd($"{address.ServerFlag}-{address.Code}", ep => new Lazy <ITransportClient>(() => { ITransportClient client = null; ClientCreatorDelegate?.Invoke(address, ref client); return(client); })).Value; _logger.Debug($"成功创建传输客户端: {address.Code}"); return(val); } catch (Exception ex) { Clients.TryRemove($"{address.ServerFlag}-{address.Code}", out _); _logger.Error($"创建传输客户端失败 : {address.Code}", ex); throw; } }
public ITransportClient CreateClient <T>(T address) where T : JimuAddress { try { _logger.Debug($"creating transport client for: {address.Code}"); //return Clients.GetOrAdd(address.CreateEndPoint(), ep => new Lazy<ITransportClient>(() => var val = Clients.GetOrAdd($"{address.ServerFlag}-{address.Code}", ep => new Lazy <ITransportClient>(() => { ITransportClient client = null; ClientCreatorDelegate?.Invoke(address, ref client); return(client); })).Value; _logger.Debug($"succed to create transport client for: {address.Code}"); return(val); } catch (Exception ex) { //Clients.TryRemove(address.CreateEndPoint(), out _); Clients.TryRemove($"{address.ServerFlag}-{address.Code}", out _); _logger.Error($"failed to create transport client for : {address.Code}", ex); throw new TransportException(ex.Message, ex); } }