Esempio n. 1
0
        private static async Task <IChangeFeedProcessor> RunChangeFeedProcessorAsync(string uri, string key, string collection)
        {
            IChangeFeedDocumentClient dbClient = new ChangeFeedDocumentClient(new DocumentClient(new Uri(uri), key));

            dbClient = new QoSMeteringChangeFeedDocumentClient(dbClient, new QoSMeteringReporter());


            var builder = new ChangeFeedProcessorBuilder()
                          .WithObserver <ConsoleObserver>()
                          .WithHostName("console_app_host")
                          .WithFeedCollection(new DocumentCollectionInfo()
            {
                Uri            = new Uri(uri),
                MasterKey      = key,
                CollectionName = collection,
                DatabaseName   = DbName
            })
                          .WithLeaseCollection(new DocumentCollectionInfo()
            {
                CollectionName = $"{collection}.Lease.ConsoleApp",
                DatabaseName   = DbName,
                Uri            = new Uri(uri),
                MasterKey      = key
            })
                          .WithFeedDocumentClient(dbClient)
                          .WithLeaseDocumentClient(dbClient);

            var processor = await builder.BuildAsync();

            var estimator = await builder.BuildEstimatorAsync();

            await processor.StartAsync().ConfigureAwait(false);

            return(processor);
        }
Esempio n. 2
0
        private static async Task <IRemainingWorkEstimator> CreateEstimatorAsync(string uri, string key, string collection)
        {
            IChangeFeedDocumentClient dbClient = new ChangeFeedDocumentClient(new DocumentClient(new Uri(uri), key));

            dbClient = new QoSMeteringChangeFeedDocumentClient(dbClient, new QoSMeteringReporter());

            var builder = new ChangeFeedProcessorBuilder()
                          .WithObserver <ConsoleObserver>()
                          .WithHostName("console_app_host")
                          .WithFeedCollection(new DocumentCollectionInfo()
            {
                Uri            = new Uri(uri),
                MasterKey      = key,
                CollectionName = collection,
                DatabaseName   = DbName
            })
                          .WithLeaseCollection(new DocumentCollectionInfo()
            {
                CollectionName = $"{collection}.Lease.ConsoleApp",
                DatabaseName   = DbName,
                Uri            = new Uri(uri),
                MasterKey      = key
            })
                          .WithFeedDocumentClient(dbClient)
                          .WithLeaseDocumentClient(dbClient);

            //var processor = await builder.BuildAsync(); (build change feed processor instance)

            return(await builder.BuildEstimatorAsync());
        }