/// <summary> /// Initializes a new instance of the <see cref="ChangeFeedEventHost"/> class. /// </summary> /// <param name="hostName">Unique name for this host.</param> /// <param name="feedCollectionLocation">Specifies location of the Cosmos DB collection to monitor changes for.</param> /// <param name="leaseCollectionLocation">Specifies location of auxiliary data for load-balancing instances of <see cref="ChangeFeedEventHost" />.</param> /// <param name="changeFeedHostOptions">Additional options to control load-balancing of <see cref="ChangeFeedEventHost" /> instances.</param> public ChangeFeedEventHost( string hostName, DocumentCollectionInfo feedCollectionLocation, DocumentCollectionInfo leaseCollectionLocation, ChangeFeedHostOptions changeFeedHostOptions) : this(hostName, feedCollectionLocation, leaseCollectionLocation, new ChangeFeedOptions(), changeFeedHostOptions) { }
/// <summary> /// Initializes a new instance of the <see cref="ChangeFeedEventHost"/> class. /// </summary> /// <param name="hostName">Unique name for this host.</param> /// <param name="feedCollectionLocation">Specifies location of the Cosmos DB collection to monitor changes for.</param> /// <param name="leaseCollectionLocation">Specifies location of auxiliary data for load-balancing instances of <see cref="ChangeFeedEventHost" />.</param> /// <param name="changeFeedOptions">Options to pass to the DocumentClient.CreateDocumentChangeFeedQuery API.</param> /// <param name="changeFeedHostOptions">Additional options to control load-balancing of <see cref="ChangeFeedEventHost" /> instances.</param> public ChangeFeedEventHost( string hostName, DocumentCollectionInfo feedCollectionLocation, DocumentCollectionInfo leaseCollectionLocation, ChangeFeedOptions changeFeedOptions, ChangeFeedHostOptions changeFeedHostOptions) { if (string.IsNullOrEmpty(hostName)) { throw new ArgumentNullException(nameof(hostName)); } if (feedCollectionLocation == null) { throw new ArgumentNullException(nameof(feedCollectionLocation)); } if (leaseCollectionLocation == null) { throw new ArgumentNullException(nameof(leaseCollectionLocation)); } if (changeFeedOptions == null) { throw new ArgumentNullException(nameof(changeFeedOptions)); } if (changeFeedHostOptions == null) { throw new ArgumentNullException(nameof(changeFeedHostOptions)); } ChangeFeedEventHost.TraceLogProvider.OpenNestedContext(hostName); this.builder .WithHostName(hostName) .WithFeedCollection(feedCollectionLocation) .WithProcessorOptions(ChangeFeedEventHost.CreateProcessorOptions(changeFeedOptions, changeFeedHostOptions)) .WithLeaseCollection(leaseCollectionLocation); }
internal static ChangeFeedProcessorOptions CreateProcessorOptions(ChangeFeedOptions feedOptions, ChangeFeedHostOptions hostOptions) { Debug.Assert(feedOptions != null, nameof(feedOptions)); Debug.Assert(hostOptions != null, nameof(hostOptions)); if (!string.IsNullOrEmpty(feedOptions.PartitionKeyRangeId)) { throw new ArgumentException("changeFeedOptions.PartitionKeyRangeId must be null or empty string.", nameof(feedOptions.PartitionKeyRangeId)); } if (feedOptions.PartitionKey != null) { throw new ArgumentException("changeFeedOptions.PartitionKey must be null.", nameof(feedOptions.PartitionKey)); } if (hostOptions.DiscardExistingLeases) { throw new ArgumentException("hostOptions.DiscardExistingLeases is no longer supported.", nameof(hostOptions.DiscardExistingLeases)); } return(new ChangeFeedProcessorOptions { MaxItemCount = feedOptions.MaxItemCount, StartFromBeginning = feedOptions.StartFromBeginning, StartTime = feedOptions.StartTime, RequestContinuation = feedOptions.RequestContinuation, SessionToken = feedOptions.SessionToken, LeaseRenewInterval = hostOptions.LeaseRenewInterval, LeaseAcquireInterval = hostOptions.LeaseAcquireInterval, LeaseExpirationInterval = hostOptions.LeaseExpirationInterval, FeedPollDelay = hostOptions.FeedPollDelay, CheckpointFrequency = hostOptions.CheckpointFrequency, LeasePrefix = hostOptions.LeasePrefix, MinPartitionCount = hostOptions.MinPartitionCount, MaxPartitionCount = hostOptions.MaxPartitionCount, DiscardExistingLeases = hostOptions.DiscardExistingLeases, QueryPartitionsMaxBatchSize = hostOptions.QueryPartitionsMaxBatchSize, }); }