Exemplo n.º 1
0
        public async Task StartAsync()
        {
            monitorCollection = CosmosDbConfig.GetMonitorConfig();

            leaseCollection = CosmosDbConfig.GetLeaseConfig();

            destinationCollection = CosmosDbConfig.GetDestinationConfig();

            monitorClientExtension = new SqlClientExtension(
                monitorCollection,
                ConsistencyLevel.Session,
                ConnectionPolicy.Default);

            leaseClientExtension = new SqlClientExtension(
                leaseCollection,
                ConsistencyLevel.Session,
                ConnectionPolicy.Default);

            destClientExtension = new SqlClientExtension(
                destinationCollection,
                ConsistencyLevel.Session,
                ConnectionPolicy.Default);

            // Not advised to use this code in production.
            this.CreateCollectionsInDevMode();

            await this.RunChangeFeedHostAsync();
        }
Exemplo n.º 2
0
        public async Task <IChangeFeedProcessor> StartAsync()
        {
            monitorCollection = CosmosDbConfig.GetMonitorConfig(this.logger);
            leaseCollection   = CosmosDbConfig.GetLeaseConfig(this.logger);

            monitorClientExtension = new SqlClientExtension(
                monitorCollection,
                ConsistencyLevel.Session,
                ConnectionPolicy.Default);

            leaseClientExtension = new SqlClientExtension(
                leaseCollection,
                ConsistencyLevel.Session,
                ConnectionPolicy.Default);

            DestinationType?destinationType = ConfigHelper.GetDestinationType(this.logger);

            if (destinationType == DestinationType.CosmosDB)
            {
                destinationCollection = CosmosDbConfig.GetDestinationConfig(this.logger);

                destClientExtension = new SqlClientExtension(
                    destinationCollection,
                    ConsistencyLevel.Session,
                    ConnectionPolicy.Default);
            }
            else if (destinationType == DestinationType.MongoDB)
            {
                string destConnectionString =
                    ConfigurationManager.AppSettings["dest-conn"];
                MongoClientSettings destSettings = MongoClientSettings.FromUrl(
                    new MongoUrl(destConnectionString)
                    );
                destMongoClient        = new MongoClient(destSettings);
                destDatabase           = destMongoClient.GetDatabase(destDbName);
                destDocStoreCollection = destDatabase.GetCollection <BsonDocument>(destCollectionName);
            }

            // Not advised to use this code in production.
            this.CreateCollectionsInDevMode();

            return(await this.RunChangeFeedHostAsync());
        }