Пример #1
0
        public async Task AddQueryAsync(string queryName, string cursorName)
        {
            using (var entityContext = new EntityContext())
            {
                var query = await GetQueryAsync(queryName, entityContext);

                if (query == null)
                {
                    var cursorService = new CursorService();
                    await cursorService.EnsureExistsAsync(cursorName);

                    var cursor = await cursorService.GetAsync(cursorName);

                    query = new PackageQueryEntity
                    {
                        Name      = queryName,
                        CursorKey = cursor.CursorKey,
                    };

                    entityContext.PackageQueries.Add(query);

                    await entityContext.SaveChangesAsync();
                }
                else if (query.Cursor.Name != cursorName)
                {
                    throw new ArgumentException($"The query {queryName} is not using cursor {cursorName}.");
                }
            }
        }
Пример #2
0
 public DependenciesToDatabaseCommitCollector(
     CursorService cursorService,
     ICommitEnumerator <PackageEntity> enumerator,
     DependenciesToDatabaseCommitProcessor processor,
     ILogger <DependenciesToDatabaseCommitCollector> logger) : base(cursorService, enumerator, processor, logger)
 {
 }
        public async Task ProcessAsync(CancellationToken token)
        {
            var cursorService = new CursorService();
            var start         = await cursorService.GetValueAsync(_processor.CursorName);

            DateTimeOffset end;
            var            dependencyCursorNames = _processor.DependencyCursorNames;

            if (dependencyCursorNames.Any())
            {
                end = await cursorService.GetMinimumAsync(dependencyCursorNames);
            }
            else
            {
                end = DateTimeOffset.UtcNow;
            }

            _taskQueue.Start();
            var failureTask             = _taskQueue.FailureTask;
            var produceThenCompleteTask = ProduceThenCompleteAsync(start, end, token);
            var firstTask = await Task.WhenAny(failureTask, produceThenCompleteTask);

            if (firstTask == failureTask)
            {
                await await failureTask;
            }
            else
            {
                await produceThenCompleteTask;
            }
        }
Пример #4
0
 public MZipCommitCollector(
     CursorService cursorService,
     ICommitEnumerator <PackageEntity> enumerator,
     MZipCommitProcessor processor,
     ILogger <MZipCommitCollector> logger) : base(cursorService, enumerator, processor, logger)
 {
 }
 public V2ToDatabaseProcessor(
     CursorService cursorService,
     V2Client v2Client,
     PackageService service,
     ExplorePackagesSettings settings)
 {
     _cursorService = cursorService;
     _v2Client      = v2Client;
     _service       = service;
     _settings      = settings;
 }
Пример #6
0
 public CommitCollector(
     CursorService cursorService,
     ICommitEnumerator <TEntity> enumerator,
     ICommitProcessor <TEntity, TItem> processor,
     ILogger logger)
 {
     _cursorService = cursorService;
     _enumerator    = enumerator;
     _processor     = processor;
     _logger        = logger;
 }
        private async Task WorkAsync(Work work)
        {
            if (!work.Leaves.Any())
            {
                return;
            }

            await _processor.ProcessAsync(work.Page, work.Leaves);

            var cursorService = new CursorService();
            await cursorService.SetValueAsync(_processor.CursorName, work.Leaves.Last().CommitTimeStamp);
        }
 public RemoteCursorService(
     ServiceIndexCache serviceIndexCache,
     HttpSource httpSource,
     SearchServiceCursorReader searchServiceCursorReader,
     CursorService cursorService,
     ILogger <RemoteCursorService> logger)
 {
     _serviceIndexCache         = serviceIndexCache;
     _httpSource                = httpSource;
     _searchServiceCursorReader = searchServiceCursorReader;
     _cursorService             = cursorService;
     _logger = logger;
 }
Пример #9
0
 public PackageQueryProcessor(
     PackageQueryContextBuilder contextBuilder,
     CursorService cursorService,
     PackageCommitEnumerator packageCommitEnumerator,
     PackageQueryService queryService,
     IPackageService packageService,
     ILogger <PackageQueryProcessor> logger)
 {
     _contextBuilder          = contextBuilder;
     _cursorService           = cursorService;
     _packageCommitEnumerator = packageCommitEnumerator;
     _queryService            = queryService;
     _packageService          = packageService;
     _logger = logger;
 }