Example #1
0
        internal MergeRequestManager(
            DataCacheContext dataCacheContext,
            InternalCacheUpdater cacheUpdater,
            string hostname,
            IHostProperties hostProperties,
            DataCacheConnectionContext context,
            IModificationNotifier modificationNotifier)
        {
            _dataCacheContext     = dataCacheContext;
            _cacheUpdater         = cacheUpdater;
            _modificationNotifier = modificationNotifier;

            _modificationNotifier.MergeRequestModified += onMergeRequestModified;

            if (context.UpdateRules.UpdateMergeRequestsPeriod.HasValue)
            {
                DataCacheConnectionContext updateContext = new DataCacheConnectionContext(
                    new DataCacheCallbacks(null, null), // disable callbacks from updates
                    context.UpdateRules,
                    context.CustomData);

                _updateManager = new UpdateManager(_dataCacheContext, hostname, hostProperties,
                                                   updateContext, _cacheUpdater);
                _updateManager.MergeRequestEvent += onUpdate;
            }
        }
Example #2
0
 public ProjectBasedProjectListLoader(DataCacheOperator op,
                                      InternalCacheUpdater cacheUpdater, DataCacheConnectionContext dataCacheConnectionContext)
     : base(op)
 {
     _cacheUpdater = cacheUpdater;
     _dataCacheConnectionContext = dataCacheConnectionContext;
     Debug.Assert(_dataCacheConnectionContext.CustomData is ProjectBasedContext);
 }
 internal SearchBasedProjectListLoader(string hostname, DataCacheOperator op,
                                       InternalCacheUpdater cacheUpdater, DataCacheConnectionContext dataCacheConnectionContext)
     : base(op)
 {
     _hostname     = hostname;
     _cacheUpdater = cacheUpdater;
     _dataCacheConnectionContext = dataCacheConnectionContext;
     Debug.Assert(_dataCacheConnectionContext.CustomData is SearchBasedContext);
 }
Example #4
0
        private async Task startUserBasedWorkflowAsync(string hostname)
        {
            onLoadAllMergeRequests(hostname);

            DataCacheConnectionContext connectionContext = new DataCacheConnectionContext(
                new DataCacheCallbacks(onForbiddenProject, onNotFoundProject),
                new DataCacheUpdateRules(Program.Settings.AutoUpdatePeriodMs, Program.Settings.AutoUpdatePeriodMs),
                getCustomDataForUserBasedWorkflow());

            await _liveDataCache.Connect(new GitLabInstance(hostname, Program.Settings), connectionContext);

            onAllMergeRequestsLoaded(hostname, _liveDataCache.MergeRequestCache.GetProjects());
            cleanupReviewedRevisions(hostname);
        }
Example #5
0
        async private Task loadAllSearchMergeRequests(string hostname, object query, int?maxResults)
        {
            SearchCriteria searchCriteria = new SearchCriteria(new object[] { query });

            onLoadAllSearchMergeRequests(searchCriteria, hostname);

            DataCacheConnectionContext sessionContext = new DataCacheConnectionContext(
                new DataCacheCallbacks(null, null),
                new DataCacheUpdateRules(null, null),
                new SearchBasedContext(searchCriteria, maxResults, false));

            await _searchDataCache.Connect(new GitLabInstance(hostname, Program.Settings), sessionContext);

            foreach (ProjectKey projectKey in _searchDataCache.MergeRequestCache.GetProjects())
            {
                onProjectSearchMergeRequestsLoaded(projectKey,
                                                   _searchDataCache.MergeRequestCache.GetMergeRequests(projectKey));
            }

            onAllSearchMergeRequestsLoaded();
        }
Example #6
0
        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();
        }
Example #7
0
        private async Task startProjectBasedWorkflowAsync(string hostname)
        {
            IEnumerable <ProjectKey> enabledProjects =
                ConfigurationHelper.GetEnabledProjectNames(hostname, Program.Settings)
                .Select(x => new ProjectKey(hostname, x));

            if (!enabledProjects.Any())
            {
                throw new NoProjectsException(hostname);
            }

            onLoadAllMergeRequests(enabledProjects, hostname);

            DataCacheConnectionContext connectionContext = new DataCacheConnectionContext(
                new DataCacheCallbacks(onForbiddenProject, onNotFoundProject),
                new DataCacheUpdateRules(Program.Settings.AutoUpdatePeriodMs, Program.Settings.AutoUpdatePeriodMs),
                new ProjectBasedContext(enabledProjects.ToArray()));

            await _liveDataCache.Connect(new GitLabInstance(hostname, Program.Settings), connectionContext);

            onAllMergeRequestsLoaded(hostname, enabledProjects);
            cleanupReviewedRevisions(hostname);
        }
Example #8
0
        internal DiscussionManager(
            DataCacheContext dataCacheContext,
            string hostname,
            IHostProperties hostProperties,
            User user,
            IMergeRequestCache mergeRequestCache,
            DataCacheConnectionContext dataCacheConnectionContext,
            IModificationNotifier modificationNotifier)
        {
            _operator = new DiscussionOperator(hostname, hostProperties);

            _parser = new DiscussionParser(this, dataCacheContext.DiscussionKeywords, user);
            _parser.DiscussionEvent += onDiscussionParserEvent;

            _mergeRequestFilterChecker = dataCacheContext.MergeRequestFilterChecker;

            _mergeRequestCache = mergeRequestCache;
            _mergeRequestCache.MergeRequestEvent += OnMergeRequestEvent;
            _modificationNotifier = modificationNotifier;

            _modificationNotifier.DiscussionResolved += onDiscussionModified;

            if (dataCacheConnectionContext.UpdateRules.UpdateDiscussionsPeriod.HasValue)
            {
                _timer = new System.Timers.Timer
                {
                    Interval = dataCacheConnectionContext.UpdateRules.UpdateDiscussionsPeriod.Value
                };
                _timer.Elapsed            += onTimer;
                _timer.SynchronizingObject = dataCacheContext.SynchronizeInvoke;
                _timer.Start();

                scheduleUpdate(null /* update all merge requests cached at the moment of update processing */,
                               DiscussionUpdateType.InitialSnapshot);
            }
        }
Example #9
0
        internal static IMergeRequestListLoader CreateMergeRequestListLoader(string hostname,
                                                                             DataCacheOperator op, DataCacheConnectionContext context, InternalCacheUpdater cache)
        {
            IVersionLoader versionLoader = new VersionLoader(op, cache);

            IMergeRequestListLoader listLoader = null;

            if (context.CustomData is ProjectBasedContext)
            {
                listLoader = new ProjectBasedMergeRequestLoader(
                    op, versionLoader, cache, context);
            }
            else if (context.CustomData is SearchBasedContext)
            {
                listLoader = new SearchBasedMergeRequestLoader(hostname,
                                                               op, versionLoader, cache, context);
            }
            return(listLoader);
        }
 async private Task connectLiveDataCacheAsync(SearchQueryCollection queryCollection)
 {
     DataCacheConnectionContext connectionContext = new DataCacheConnectionContext(queryCollection);
     DataCache dataCache = getDataCache(EDataCacheType.Live);
     await dataCache.Connect(_gitLabInstance, connectionContext);
 }