public MobileRequestRepo(IWebProxy proxy, IAuth auth, int listDepth) : base(new Credentials(auth.Login, auth.Password)) { _listDepth = listDepth; HttpSettings.Proxy = proxy; Authent = auth; _metaServer = new Cached <ServerRequestResult>(old => { Logger.Debug("MetaServer expired, refreshing."); var server = new MobMetaServerRequest(HttpSettings).MakeRequestAsync().Result; return(server); }, value => TimeSpan.FromSeconds(MetaServerExpiresSec)); //_downloadServer = new Cached<ServerRequestResult>(old => // { // Logger.Debug("DownloadServer expired, refreshing."); // var server = new GetServerRequest(HttpSettings).MakeRequestAsync().Result; // return server; // }, // value => TimeSpan.FromSeconds(DownloadServerExpiresSec)); }
public ShardManager(IRequestRepo repo) { var httpsettings = repo.HttpSettings; _metaServer = new Cached <ServerRequestResult>(_ => { Logger.Debug("Requesting new meta server"); var server = new MobMetaServerRequest(httpsettings).MakeRequestAsync().Result; return(server); }, _ => TimeSpan.FromSeconds(MetaServerExpiresSec)); BannedShards = new Cached <List <ShardInfo> >(_ => new List <ShardInfo>(), _ => TimeSpan.FromMinutes(2)); //CachedShards = new Cached<Dictionary<ShardType, ShardInfo>>(old => new ShardInfoRequest(httpsettings, auth).MakeRequestAsync().Result.ToShardInfo(), // value => TimeSpan.FromSeconds(ShardsExpiresInSec)); CachedShards = new Cached <Dictionary <ShardType, ShardInfo> >(_ => repo.GetShardInfo1(), _ => TimeSpan.FromSeconds(ShardsExpiresInSec)); DownloadServersPending = new Pending <Cached <ServerRequestResult> >(8, () => new Cached <ServerRequestResult>(_ => { var server = new GetServerRequest(httpsettings).MakeRequestAsync().Result; Logger.Debug($"Download server changed to {server.Url}"); return(server); }, _ => TimeSpan.FromSeconds(DownloadServerExpiresSec) )); UploadServer = new Cached <ShardInfo>(_ => { var server = new GetUploadServerRequest(httpsettings).MakeRequestAsync().Result; Logger.Debug($"Upload server changed to {server.Url}"); return(new ShardInfo { Count = 0, Type = ShardType.Upload, Url = server.Url }); }, _ => TimeSpan.FromSeconds(ShardsExpiresInSec)); WeblinkDownloadServersPending = new Pending <Cached <ServerRequestResult> >(8, () => new Cached <ServerRequestResult>(_ => { var data = new WeblinkGetServerRequest(httpsettings).MakeRequestAsync().Result; var serverUrl = data.Body.WeblinkGet[0].Url; Logger.Debug($"weblink Download server changed to {serverUrl}"); var res = new ServerRequestResult { Url = serverUrl }; return(res); }, _ => TimeSpan.FromSeconds(DownloadServerExpiresSec) )); }
//public int PendingDownloads { get; set; } public MobileRequestRepo(IWebProxy proxy, IAuth auth) { HttpSettings.Proxy = proxy; Authent = auth; _metaServer = new Cached <MobMetaServerRequest.Result>(old => { Logger.Debug("MetaServer expired, refreshing."); var server = new MobMetaServerRequest(HttpSettings).MakeRequestAsync().Result; return(server); }, value => TimeSpan.FromSeconds(MetaServerExpiresSec)); _downloadServer = new Cached <ServerRequest.Result>(old => { Logger.Debug("DownloadServer expired, refreshing."); var server = new GetServerRequest(HttpSettings).MakeRequestAsync().Result; return(server); }, value => TimeSpan.FromSeconds(DownloadServerExpiresSec)); }