public LeaseStore(IChangeFeedDocumentClient client, DocumentCollectionInfo leaseStoreCollectionInfo, string containerNamePrefix, string leaseStoreCollectionLink) { this.client = client; this.leaseStoreCollectionInfo = leaseStoreCollectionInfo; this.containerNamePrefix = containerNamePrefix; this.leaseStoreCollectionLink = leaseStoreCollectionLink; }
/// <summary> /// /// </summary> /// <returns></returns> static async Task RunProcessingAsync() { DocumentCollectionInfo feedCollectionInfo = new DocumentCollectionInfo() { DatabaseName = Constants.CosmosDb_DatabaseName, CollectionName = Constants.CosmosDb_CollectionName, Uri = new Uri(Constants.CosmosDb_Uri), MasterKey = Constants.CosmosDb_Key }; DocumentCollectionInfo leaseCollectionInfo = new DocumentCollectionInfo() { DatabaseName = Constants.CosmosDb_DatabaseName, CollectionName = "leases", Uri = new Uri(Constants.CosmosDb_Uri), MasterKey = Constants.CosmosDb_Key }; var builder = new ChangeFeedProcessorBuilder(); var processor = await builder .WithHostName("ProductChangeObserverHost") .WithFeedCollection(feedCollectionInfo) .WithLeaseCollection(leaseCollectionInfo) .WithObserver <ProductChangeObserver>() .BuildAsync(); await processor.StartAsync(); Console.WriteLine("Change Feed Processor started. Press <Enter> key to stop..."); Console.ReadLine(); await processor.StopAsync(); }
public CosmosDBTriggerBinding(ParameterInfo parameter, DocumentCollectionInfo documentCollectionLocation, DocumentCollectionInfo leaseCollectionLocation, ChangeFeedHostOptions leaseHostOptions) { _documentCollectionLocation = documentCollectionLocation; _leaseCollectionLocation = leaseCollectionLocation; _leaseHostOptions = leaseHostOptions; _parameter = parameter; }
public CosmosDBTriggerListener(ITriggeredFunctionExecutor executor, DocumentCollectionInfo documentCollectionLocation, DocumentCollectionInfo leaseCollectionLocation, ChangeFeedHostOptions leaseHostOptions) { this.executor = executor; string hostName = Guid.NewGuid().ToString(); this.host = new ChangeFeedEventHost(hostName, documentCollectionLocation, leaseCollectionLocation, new ChangeFeedOptions(), leaseHostOptions); }
public async Task <IChangeFeedProcessor> RunCosmosDBSink( DocumentCollectionInfo monitorDocumentCollectionInfo, DocumentCollectionInfo leaseDocumentCollectionInfo) { string hostName = Guid.NewGuid().ToString(); this.logger.LogInformation("Cosmos DB Sink Host name {0}", hostName); // destination collection info DocumentCollectionInfo destCollInfo = new DocumentCollectionInfo { Uri = new Uri(destinationCollection.AccountEndPoint), MasterKey = destinationCollection.Key, DatabaseName = destinationCollection.DbName, CollectionName = destinationCollection.CollectionName }; DocumentClient destClient = new DocumentClient(destCollInfo.Uri, destCollInfo.MasterKey); ChangeFeedObserverFactory docConsumerFactory = new ChangeFeedObserverFactory( destClientExtension, cosmosDbSink, this.loggerFactory); return(await GetChangeFeedProcessor( docConsumerFactory, hostName, monitorDocumentCollectionInfo, leaseDocumentCollectionInfo)); }
public CosmosDBTriggerListener(ITriggeredFunctionExecutor executor, string functionId, DocumentCollectionInfo documentCollectionLocation, DocumentCollectionInfo leaseCollectionLocation, ChangeFeedProcessorOptions processorOptions, ICosmosDBService monitoredCosmosDBService, ICosmosDBService leasesCosmosDBService, ILogger logger, IRemainingWorkEstimator workEstimator = null) { this._logger = logger; this._executor = executor; this._functionId = functionId; this._hostName = Guid.NewGuid().ToString(); this._monitorCollection = documentCollectionLocation; this._leaseCollection = leaseCollectionLocation; this._processorOptions = processorOptions; this._monitoredCosmosDBService = monitoredCosmosDBService; this._leasesCosmosDBService = leasesCosmosDBService; this._healthMonitor = new CosmosDBTriggerHealthMonitor(this._logger); this._workEstimator = workEstimator; this._scaleMonitorDescriptor = new ScaleMonitorDescriptor($"{_functionId}-CosmosDBTrigger-{_monitorCollection.DatabaseName}-{_monitorCollection.CollectionName}".ToLower()); }
public async Task <IChangeFeedProcessor> GetChangeFeedProcessor( Microsoft.Azure.Documents.ChangeFeedProcessor.FeedProcessing.IChangeFeedObserverFactory changeFeedObserverFactory, string hostName, DocumentCollectionInfo monitorDocumentCollectionInfo, DocumentCollectionInfo leaseDocumentCollectionInfo) { ChangeFeedConfig changeFeedConfig = ChangeFeedConfig.GetChangeFeedConfig(); ChangeFeedProcessorOptions processorOptions = new ChangeFeedProcessorOptions(); processorOptions.StartFromBeginning = true; processorOptions.MaxItemCount = changeFeedConfig.MaxItemCount; processorOptions.LeaseRenewInterval = changeFeedConfig.LeaseRenewInterval; this.logger.LogInformation("Processor options Starts from Beginning - {0}, Lease renew interval - {1}", processorOptions.StartFromBeginning, processorOptions.LeaseRenewInterval.ToString()); var processor = await new ChangeFeedProcessorBuilder() .WithObserverFactory(changeFeedObserverFactory) .WithHostName(hostName) .WithFeedCollection(monitorDocumentCollectionInfo) .WithLeaseCollection(leaseDocumentCollectionInfo) .WithProcessorOptions(processorOptions) .BuildAsync(); await processor.StartAsync().ConfigureAwait(false); return(processor); }
static async Task RunAsync() { DocumentCollectionInfo feedCollectionInfo = new DocumentCollectionInfo() { DatabaseName = "Sjaas", CollectionName = "Job", Uri = new Uri("to-be-filled"), MasterKey = "to-be-filled" }; DocumentCollectionInfo leaseCollectionInfo = new DocumentCollectionInfo() { DatabaseName = "Sjaas", CollectionName = "Lease", Uri = new Uri("to-be-filled"), MasterKey = "to-be-filled" }; var builder = new ChangeFeedProcessorBuilder(); var processor = await builder .WithHostName("SjaasWorker") .WithFeedCollection(feedCollectionInfo) .WithLeaseCollection(leaseCollectionInfo) .WithObserver <SjaasWorker>() .BuildAsync(); await processor.StartAsync(); Console.WriteLine("Change Feed Processor started. Press <Enter> key to stop..."); Console.ReadLine(); await processor.StopAsync(); }
public CosmosDBListenerTests() { _loggerFactory = new LoggerFactory(); _loggerFactory.AddProvider(_loggerProvider); _mockExecutor = new Mock <ITriggeredFunctionExecutor>(); _functionId = "testfunctionid"; _mockMonitoredService = new Mock <ICosmosDBService>(MockBehavior.Strict); _mockMonitoredService.Setup(m => m.GetClient()).Returns(new DocumentClient(new Uri("http://someurl"), "c29tZV9rZXk=")); _monitoredInfo = new DocumentCollectionInfo { Uri = new Uri("http://someurl"), MasterKey = "c29tZV9rZXk=", DatabaseName = "MonitoredDB", CollectionName = "MonitoredCollection" }; _mockLeasesService = new Mock <ICosmosDBService>(MockBehavior.Strict); _mockLeasesService.Setup(m => m.GetClient()).Returns(new DocumentClient(new Uri("http://someurl"), "c29tZV9rZXk=")); _leasesInfo = new DocumentCollectionInfo { Uri = new Uri("http://someurl"), MasterKey = "c29tZV9rZXk=", DatabaseName = "LeasesDB", CollectionName = "LeasesCollection" }; _processorOptions = new ChangeFeedProcessorOptions(); // Mock the work estimator so this doesn't require a CosmosDB instance. _mockWorkEstimator = new Mock <IRemainingWorkEstimator>(MockBehavior.Strict); _listener = new CosmosDBTriggerListener(_mockExecutor.Object, _functionId, _monitoredInfo, _leasesInfo, _processorOptions, _mockMonitoredService.Object, _mockLeasesService.Object, _loggerFactory.CreateLogger <CosmosDBTriggerListener>(), _mockWorkEstimator.Object); }
public async Task StartAsync() { var feedCollectionInfo = new DocumentCollectionInfo { DatabaseName = _database, CollectionName = _eventContainer, Uri = new Uri(_endpointUri), MasterKey = _authKey }; var leaseCollectionInfo = new DocumentCollectionInfo { DatabaseName = _database, CollectionName = _leaseContainer, Uri = new Uri(_endpointUri), MasterKey = _authKey }; var viewRepository = new CosmosDBViewRepository(_endpointUri, _authKey, _database); var builder = new ChangeFeedProcessorBuilder(); _changeFeedProcessor = await builder .WithHostName("ProjectionHost") .WithFeedCollection(feedCollectionInfo) .WithLeaseCollection(leaseCollectionInfo) .WithObserverFactory(new EventObserverFactory(_projections, viewRepository)) .WithProcessorOptions(new ChangeFeedProcessorOptions { StartFromBeginning = true }) .BuildAsync(); await _changeFeedProcessor.StartAsync(); }
internal static void GetConfigurationSettings( out DocumentCollectionInfo monitoredCollectionInfo, out DocumentCollectionInfo leaseCollectionInfo, out int monitoredOfferThroughput, out int leaseOfferThroughput) { monitoredCollectionInfo = new DocumentCollectionInfo { Uri = new Uri(ConfigurationManager.AppSettings["endpoint"]), MasterKey = ConfigurationManager.AppSettings["masterKey"], DatabaseName = ConfigurationManager.AppSettings["databaseId"], ConnectionPolicy = new ConnectionPolicy { ConnectionMode = ConnectionMode.Gateway } }; leaseCollectionInfo = new DocumentCollectionInfo { Uri = new Uri(ConfigurationManager.AppSettings["endpoint"]), MasterKey = ConfigurationManager.AppSettings["masterKey"], DatabaseName = ConfigurationManager.AppSettings["databaseId"], ConnectionPolicy = new ConnectionPolicy { ConnectionMode = ConnectionMode.Gateway } }; monitoredOfferThroughput = int.Parse(ConfigurationManager.AppSettings["monitoredOfferThroughput"]); leaseOfferThroughput = int.Parse(ConfigurationManager.AppSettings["leaseOfferThroughput"]); }
internal static void GetConfigurationSettings( out DocumentCollectionInfo monitoredCollectionInfo, out DocumentCollectionInfo leaseCollectionInfo, out int monitoredOfferThroughput, out int leaseOfferThroughput) { monitoredCollectionInfo = new DocumentCollectionInfo { Uri = new Uri(IntegrationTestsHelper.Endpoint), MasterKey = IntegrationTestsHelper.MasterKey, DatabaseName = IntegrationTestsHelper.DatabaseId, ConnectionPolicy = new ConnectionPolicy { ConnectionMode = ConnectionMode.Gateway } }; leaseCollectionInfo = new DocumentCollectionInfo { Uri = new Uri(IntegrationTestsHelper.Endpoint), MasterKey = IntegrationTestsHelper.MasterKey, DatabaseName = IntegrationTestsHelper.DatabaseId, ConnectionPolicy = new ConnectionPolicy { ConnectionMode = ConnectionMode.Gateway } }; monitoredOfferThroughput = int.Parse(IntegrationTestsHelper.MonitoredOfferThroughput); leaseOfferThroughput = int.Parse(IntegrationTestsHelper.LeaseOfferThroughput); }
public static async Task StartChangeFeedHost() { var config = ServiceLocator.GetService <IConfiguration>(); string hostName = config.MonitoredCollectionName + "_monitor_" + Guid.NewGuid().ToString(); DocumentCollectionInfo documentCollectionLocation = new DocumentCollectionInfo { Uri = config.DatabaseAccountUri, MasterKey = config.DatabaseAccountKey, DatabaseName = config.MonitoredDatabaseName, CollectionName = config.MonitoredCollectionName }; DocumentCollectionInfo leaseCollectionLocation = new DocumentCollectionInfo { Uri = config.DatabaseAccountUri, MasterKey = config.DatabaseAccountKey, DatabaseName = config.ChangeTrackingDatabaseName, CollectionName = config.ChangeTrackingLeaseCollectionName }; Console.WriteLine("Main program: Creating ChangeFeedEventHost..."); ChangeFeedOptions feedOptions = new ChangeFeedOptions(); ChangeFeedHostOptions feedHostOptions = new ChangeFeedHostOptions(); ChangeFeedEventHost host = new ChangeFeedEventHost(hostName, documentCollectionLocation, leaseCollectionLocation, feedOptions, feedHostOptions); await host.RegisterObserverAsync <DocumentFeedObserver>(); Console.WriteLine("Main program: press Enter to stop..."); Console.ReadLine(); await host.UnregisterObserversAsync(); }
public async Task StartAsync_Retries() { var mockExecutor = new Mock <ITriggeredFunctionExecutor>(); var collInfo = new DocumentCollectionInfo { Uri = new Uri("http://fakeaccount"), MasterKey = "c29tZV9rZXk=", DatabaseName = "FakeDb", CollectionName = "FakeColl" }; var leaseInfo = new DocumentCollectionInfo { Uri = new Uri("http://fakeaccount"), MasterKey = "c29tZV9rZXk=", DatabaseName = "FakeDb", CollectionName = "leases" }; var hostOptions = new ChangeFeedHostOptions(); var feedOptions = new ChangeFeedOptions(); var listener = new MockListener(mockExecutor.Object, collInfo, leaseInfo, hostOptions, feedOptions, NullLogger.Instance); // Ensure that we can call StartAsync() multiple times to retry if there is an error. for (int i = 0; i < 3; i++) { var ex = await Assert.ThrowsAnyAsync <InvalidOperationException>(() => listener.StartAsync(CancellationToken.None)); Assert.Equal("Failed to register!", ex.Message); } // This should succeed await listener.StartAsync(CancellationToken.None); }
/// <summary> /// Registers change feed observer to update changes read on change feed to destination /// collection. Deregisters change feed observer and closes process when enter key is pressed /// </summary> /// <returns>A Task to allow asynchronous execution</returns> public async Task RunChangeFeedHostAsync() { string hostName = Guid.NewGuid().ToString(); // monitored collection info DocumentCollectionInfo documentCollectionLocation = new DocumentCollectionInfo { Uri = new Uri(this.monitoredUri), MasterKey = this.monitoredSecretKey, DatabaseName = this.monitoredDbName, CollectionName = this.monitoredCollectionName }; // lease collection info DocumentCollectionInfo leaseCollectionLocation = new DocumentCollectionInfo { Uri = new Uri(this.leaseUri), MasterKey = this.leaseSecretKey, DatabaseName = this.leaseDbName, CollectionName = this.leaseCollectionName }; // destination collection info DocumentCollectionInfo destCollInfo = new DocumentCollectionInfo { Uri = new Uri(this.destUri), MasterKey = this.destSecretKey, DatabaseName = this.destDbName, CollectionName = this.destCollectionName }; // Customizable change feed option and host options ChangeFeedOptions feedOptions = new ChangeFeedOptions(); // ie customize StartFromBeginning so change feed reads from beginning // can customize MaxItemCount, PartitonKeyRangeId, RequestContinuation, SessionToken and StartFromBeginning feedOptions.StartFromBeginning = true; ChangeFeedHostOptions feedHostOptions = new ChangeFeedHostOptions(); // ie. customizing lease renewal interval to 15 seconds // can customize LeaseRenewInterval, LeaseAcquireInterval, LeaseExpirationInterval, FeedPollDelay feedHostOptions.LeaseRenewInterval = TimeSpan.FromSeconds(15); using (DocumentClient destClient = new DocumentClient(destCollInfo.Uri, destCollInfo.MasterKey)) { DocumentFeedObserverFactory docObserverFactory = new DocumentFeedObserverFactory(destClient, destCollInfo); ChangeFeedEventHost host = new ChangeFeedEventHost(hostName, documentCollectionLocation, leaseCollectionLocation, feedOptions, feedHostOptions); await host.RegisterObserverFactoryAsync(docObserverFactory); Console.WriteLine("Running... Press enter to stop."); Console.ReadLine(); await host.UnregisterObserversAsync(); } }
static async Task Main(string[] args) { var devEnvironmentVariable = Environment.GetEnvironmentVariable("NETCORE_ENVIRONMENT"); var isDevelopment = string.IsNullOrEmpty(devEnvironmentVariable) || devEnvironmentVariable.ToLower() == "development"; var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddEnvironmentVariables(); if (isDevelopment) //only add secrets in development { builder.AddUserSecrets <UserDbSettings>(); } var configuration = builder.Build(); var services = new ServiceCollection() .Configure <UserDbSettings>(configuration.GetSection("UserDbSettings")) .Configure <LeasesDbSettings>(configuration.GetSection("LeasesDbSettings")) .AddOptions() .BuildServiceProvider(); var userCollectionDbSettings = services.GetService <IOptions <UserDbSettings> >().Value; var userCollectionInfo = new DocumentCollectionInfo() { DatabaseName = userCollectionDbSettings.DatabaseName, CollectionName = userCollectionDbSettings.CollectionName, Uri = userCollectionDbSettings.Uri, MasterKey = userCollectionDbSettings.AccountKey }; var leasesDbSettings = services.GetService <IOptions <LeasesDbSettings> >().Value; var leasesCollectionInfo = new DocumentCollectionInfo() { DatabaseName = leasesDbSettings.DatabaseName, CollectionName = leasesDbSettings.CollectionName, Uri = leasesDbSettings.Uri, MasterKey = leasesDbSettings.AccountKey }; var processor = await new ChangeFeedProcessorBuilder() .WithHostName("SampleHost") .WithFeedCollection(userCollectionInfo) .WithLeaseCollection(leasesCollectionInfo) .WithObserver <SampleObserver>() .WithProcessorOptions(new ChangeFeedProcessorOptions() { StartFromBeginning = true, }) .BuildAsync(); await processor.StartAsync(); Console.WriteLine("Change Feed Processor started. Press any key to stop..."); Console.ReadKey(true); await processor.StopAsync(); }
public CosmosDBTriggerBinding(ParameterInfo parameter, DocumentCollectionInfo documentCollectionLocation, DocumentCollectionInfo leaseCollectionLocation, ChangeFeedHostOptions leaseHostOptions, int?maxItemsPerCall) { _documentCollectionLocation = documentCollectionLocation; _leaseCollectionLocation = leaseCollectionLocation; _leaseHostOptions = leaseHostOptions; _parameter = parameter; _maxItemsPerCall = maxItemsPerCall; }
public DocumentServiceLeaseManager(DocumentCollectionInfo leaseStoreCollectionInfo, string storeNamePrefix, TimeSpan leaseInterval, TimeSpan renewInterval) { this.leaseStoreCollectionInfo = leaseStoreCollectionInfo; this.containerNamePrefix = storeNamePrefix; this.leaseInterval = leaseInterval; this.renewInterval = renewInterval; this.client = new DocumentClient(leaseStoreCollectionInfo.Uri, leaseStoreCollectionInfo.MasterKey, leaseStoreCollectionInfo.ConnectionPolicy); }
public CosmosDBTriggerBinding(ParameterInfo parameter, DocumentCollectionInfo documentCollectionLocation, DocumentCollectionInfo leaseCollectionLocation, ChangeFeedHostOptions leaseHostOptions) { _bindingDataProvider = BindingDataProvider.FromType(parameter.ParameterType); _documentCollectionLocation = documentCollectionLocation; _leaseCollectionLocation = leaseCollectionLocation; _leaseHostOptions = leaseHostOptions; _parameter = parameter; }
/// <summary> /// Initializes a new instance of the <see cref="DocumentFeedObserverFactory" /> class. /// Saves input DocumentClient and DocumentCollectionInfo parameters to class fields /// </summary> /// <param name="SourcePartitionKeys">Attributes from source collection to be mapped as PK in Target</param> /// <param name="TargetPartitionKey">PK attribute name in Target</param> /// <param name="destClient">Client connected to destination collection</param> /// <param name="destCollInfo">Destination collection information</param> /// <param name="docTransformer">Default Document Transformer</param> /// <param name="containerClient">Blob client to persist DLQ docs</param> public DocumentFeedObserverFactory(string SourcePartitionKeys, string TargetPartitionKey, DocumentClient destClient, DocumentCollectionInfo destCollInfo, IDocumentTransformer docTransformer, BlobContainerClient containerClient) { this.destCollInfo = destCollInfo; this.destClient = destClient; this.documentTransformer = docTransformer; this.containerClient = containerClient; this.SourcePartitionKeys = SourcePartitionKeys; this.TargetPartitionKey = TargetPartitionKey; }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { try { Log("ExecuteAsync"); var hostName = _cosmosSettings.HostName; var dbName = _cosmosSettings.DatabaseName; var key = _cosmosSettings.Key; var uri = _cosmosSettings.Uri; DocumentCollectionInfo feedCollectionInfo = new DocumentCollectionInfo() { DatabaseName = dbName, CollectionName = _cosmosSettings.CollectionName, Uri = new Uri(uri), MasterKey = key }; DocumentCollectionInfo leaseCollectionInfo = new DocumentCollectionInfo() { DatabaseName = dbName, CollectionName = _cosmosSettings.LeaseCollectionName, Uri = new Uri(uri), MasterKey = key }; var observerFactory = new CosmosDBObserverFactory(_memoryCache, _log); var builder = new ChangeFeedProcessorBuilder(); var processor = await builder .WithHostName(hostName) .WithFeedCollection(feedCollectionInfo) .WithLeaseCollection(leaseCollectionInfo) .WithObserverFactory(observerFactory) .BuildAsync(); Log("before StartAsync"); await processor.StartAsync(); Log("after StartAsync"); await Task.Delay(-1); Console.WriteLine("Change Feed Processor started. Press <Enter> key to stop..."); Console.ReadLine(); Log("before StopAsync"); await processor.StopAsync(); Log("after StopAsync"); } catch (Exception ex) { Log(ex.ToString()); } }
public async Task <IChangeFeedProcessor> RunChangeFeedHostAsync() { string hostName = Guid.NewGuid().ToString(); Trace.TraceInformation("Host name {0}", hostName); // monitored collection info DocumentCollectionInfo documentCollectionLocation = new DocumentCollectionInfo { Uri = new Uri(this.config.MonitoredUri), MasterKey = this.config.MonitoredSecretKey, DatabaseName = this.config.MonitoredDbName, CollectionName = this.config.MonitoredCollectionName }; // lease collection info DocumentCollectionInfo leaseCollectionLocation = new DocumentCollectionInfo { Uri = new Uri(this.config.LeaseUri), MasterKey = this.config.LeaseSecretKey, DatabaseName = this.config.LeaseDbName, CollectionName = this.config.LeaseCollectionName }; // destination collection info DocumentCollectionInfo destCollInfo = new DocumentCollectionInfo { Uri = new Uri(this.config.DestUri), MasterKey = this.config.DestSecretKey, DatabaseName = this.config.DestDbName, CollectionName = this.config.DestCollectionName }; ChangeFeedProcessorOptions processorOptions = new ChangeFeedProcessorOptions(); processorOptions.StartFromBeginning = true; processorOptions.LeaseRenewInterval = TimeSpan.FromSeconds(15); Trace.TraceInformation("Processor options Starts from Beginning - {0}, Lease renew interval - {1}", processorOptions.StartFromBeginning, processorOptions.LeaseRenewInterval.ToString()); DocumentClient destClient = new DocumentClient(destCollInfo.Uri, destCollInfo.MasterKey); DocumentFeedObserverFactory docObserverFactory = new DocumentFeedObserverFactory(destClient, destCollInfo); var processor = await new ChangeFeedProcessorBuilder() .WithObserverFactory(docObserverFactory) .WithHostName(hostName) .WithFeedCollection(documentCollectionLocation) .WithLeaseCollection(leaseCollectionLocation) .WithProcessorOptions(processorOptions) .BuildAsync(); await processor.StartAsync().ConfigureAwait(false); return(processor); }
public DocumentServiceLeaseStoreManagerBuilder WithLeaseCollection(DocumentCollectionInfo leaseCollectionLocation) { if (leaseCollectionLocation == null) { throw new ArgumentNullException(nameof(leaseCollectionLocation)); } this.settings.LeaseCollectionInfo = leaseCollectionLocation.Canonicalize(); return(this); }
public CosmosStoreTriggerBinding(ParameterInfo parameter, DocumentCollectionInfo documentCollectionLocation, DocumentCollectionInfo leaseCollectionLocation, IDocumentClient monitoredDocumentClient, IDocumentClient leaseDocumentClient, ChangeFeedProcessorOptions processorOptions, ILogger logger) { DocumentCollectionLocation = documentCollectionLocation; LeaseCollectionLocation = leaseCollectionLocation; _monitoredDocumentClient = monitoredDocumentClient; _leaseDocumentClient = leaseDocumentClient; _parameter = parameter; ChangeFeedProcessorOptions = processorOptions; _logger = logger; }
internal static IChangeFeedDocumentClient CreateDocumentClient(this DocumentCollectionInfo collectionInfo) { var internalClient = new DocumentClient( collectionInfo.Uri, collectionInfo.MasterKey, collectionInfo.ConnectionPolicy, collectionInfo.ConsistencyLevel); return(new ChangeFeedDocumentClient(internalClient)); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentFeedObserver" /> class. /// Saves input DocumentClient and DocumentCollectionInfo parameters to class fields /// </summary> /// <param name="client"> Client connected to destination collection </param> /// <param name="destinationCollection"> Destination collection information </param> public DocumentFeedObserver(DocumentClient client, DocumentCollectionInfo destinationCollection) { _client = client; _destinationCollectionUri = UriFactory.CreateDocumentCollectionUri(destinationCollection.DatabaseName, destinationCollection.CollectionName); CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["TableApi.StorageConnectionString"]); CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); _planetsTable = tableClient.GetTableReference("planets"); }
public LeaseManagerBuilder WithLeaseCollection(DocumentCollectionInfo leaseCollectionLocation) { if (leaseCollectionLocation == null) { throw new ArgumentNullException(nameof(leaseCollectionLocation)); } this.leaseCollectionLocation = leaseCollectionLocation.Canonicalize(); return(this); }
public static async Task <DocumentCollection> GetDocumentCollectionAsync( this IChangeFeedDocumentClient client, DocumentCollectionInfo collectionInfo) { Uri collectionUri = UriFactory.CreateDocumentCollectionUri(collectionInfo.DatabaseName, collectionInfo.CollectionName); IResourceResponse <DocumentCollection> response = await client.ReadDocumentCollectionAsync(collectionUri, new RequestOptions()).ConfigureAwait(false); return(response.Resource); }
public CosmosStoreTriggerListener(ITriggeredFunctionExecutor executor, DocumentCollectionInfo documentCollectionLocation, DocumentCollectionInfo leaseCollectionLocation, ChangeFeedProcessorOptions processorOptions, IDocumentClient monitoredDocumentClient, IDocumentClient leaseDocumentClient, ILogger logger) { _logger = logger; _executor = executor; _hostName = Guid.NewGuid().ToString(); _monitoredDocumentClient = monitoredDocumentClient; _leaseDocumentClient = leaseDocumentClient; _monitorCollection = documentCollectionLocation; _leaseCollection = leaseCollectionLocation; _processorOptions = processorOptions; }
public CosmosDBTriggerListener(ITriggeredFunctionExecutor executor, DocumentCollectionInfo documentCollectionLocation, DocumentCollectionInfo leaseCollectionLocation, ChangeFeedHostOptions leaseHostOptions, ChangeFeedOptions changeFeedOptions, ILogger logger) { this._logger = logger; this._executor = executor; this._hostName = Guid.NewGuid().ToString(); this._monitorCollection = documentCollectionLocation; this._leaseCollection = leaseCollectionLocation; this._leaseHostOptions = leaseHostOptions; this._changeFeedOptions = changeFeedOptions; }