async public Task Connect(GitLabInstance gitLabInstance, DataCacheConnectionContext context) { reset(); string hostname = gitLabInstance.HostName; IHostProperties hostProperties = gitLabInstance.HostProperties; _operator = new DataCacheOperator(hostname, hostProperties); try { InternalCacheUpdater cacheUpdater = new InternalCacheUpdater(new InternalCache()); IMergeRequestListLoader mergeRequestListLoader = MergeRequestListLoaderFactory.CreateMergeRequestListLoader(hostname, _operator, context, cacheUpdater); Trace.TraceInformation(String.Format("[DataCache] Starting new dataCache at {0}", hostname)); User currentUser = await new CurrentUserLoader(_operator).Load(hostname); await mergeRequestListLoader.Load(); _internal = createCacheInternal(cacheUpdater, hostname, hostProperties, currentUser, context); Trace.TraceInformation(String.Format("[DataCache] Started new dataCache at {0}", hostname)); Connected?.Invoke(hostname, currentUser); } catch (BaseLoaderException ex) { if (ex is BaseLoaderCancelledException) { throw new DataCacheConnectionCancelledException(); } throw new DataCacheException(ex.OriginalMessage, ex); } }
internal UpdateManager( DataCacheContext dataCacheContext, string hostname, IHostProperties hostProperties, DataCacheConnectionContext context, InternalCacheUpdater cacheUpdater) { DataCacheOperator updateOperator = new DataCacheOperator(hostname, hostProperties); _mergeRequestListLoader = MergeRequestListLoaderFactory.CreateMergeRequestListLoader( hostname, updateOperator, context, cacheUpdater); _mergeRequestLoader = new MergeRequestLoader(updateOperator, cacheUpdater); _cache = cacheUpdater.Cache; _timer = new System.Timers.Timer { Interval = context.UpdateRules.UpdateMergeRequestsPeriod.Value }; _timer.Elapsed += onTimer; _timer.SynchronizingObject = dataCacheContext.SynchronizeInvoke; _timer.Start(); }