Skip to content

Commit f87b0a2

Browse files
Wisgarymkolt
authored andcommitted
Adding a lease prefix to the change feed host options. (Azure#298)
* Adding a lease prefix to support pointing multiple hosts at the same collection with only one auxiliary collection * CR feedback * CR feedback
1 parent 1680b62 commit f87b0a2

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

samples/ChangeFeedProcessor/DocumentDB.ChangeFeedProcessor/ChangeFeedEventHost.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,11 @@ async Task InitializeAsync()
475475
DocumentCollection collection = collectionResponse.Resource;
476476
this.collectionSelfLink = collection.SelfLink;
477477

478-
// Beyond this point all access to colleciton is done via this self link: if collection is removed, we won't access new one using same name by accident.
479-
this.leasePrefix = string.Format(CultureInfo.InvariantCulture, "{0}_{1}_{2}", this.collectionLocation.Uri.Host, database.ResourceId, collection.ResourceId);
478+
// Grab the options-supplied prefix if present otherwise leave it empty.
479+
string optionsPrefix = this.options.LeasePrefix ?? string.Empty;
480+
481+
// Beyond this point all access to collection is done via this self link: if collection is removed, we won't access new one using same name by accident.
482+
this.leasePrefix = string.Format(CultureInfo.InvariantCulture, "{0}{1}_{2}_{3}", optionsPrefix, this.collectionLocation.Uri.Host, database.ResourceId, collection.ResourceId);
480483

481484
var leaseManager = new DocumentServiceLeaseManager(
482485
this.auxCollectionLocation,

samples/ChangeFeedProcessor/DocumentDB.ChangeFeedProcessor/ChangeFeedHostOptions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ public ChangeFeedHostOptions()
4646
/// Gets or sets the the frequency how often to checkpoint leases.
4747
/// </summary>
4848
public CheckpointFrequency CheckpointFrequency { get; set; }
49+
50+
/// <summary>
51+
/// Gets or sets a prefix to be used as part of the lease id. This can be used to support multiple <see cref="ChangeFeedEventHost"/>
52+
/// instances pointing at the same feed while using the same auxiliary collection.
53+
/// </summary>
54+
public string LeasePrefix { get; set; }
4955

5056
/// <summary>
5157
/// Gets or set the minimum partition count for the host.

0 commit comments

Comments
 (0)