Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Commit

Permalink
Fixed the best ctor error and adds collection specific lease logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Elfocrash committed Nov 29, 2018
1 parent 0f36ace commit d48c5f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@ namespace Cosmonaut.WebJobs.Extensions.Trigger
[Binding]
public sealed class CosmosStoreTriggerAttribute : Attribute
{
public CosmosStoreTriggerAttribute(string databaseName, string overridenCollectionName = null)
public CosmosStoreTriggerAttribute(string databaseName)
{
if (string.IsNullOrWhiteSpace(databaseName))
{
throw new ArgumentException("Missing information for the collection to monitor", nameof(databaseName));
}

DatabaseName = databaseName;
LeaseCollectionName = CosmosStoreTriggerConstants.DefaultLeaseCollectionName;
LeaseDatabaseName = DatabaseName;
}

public CosmosStoreTriggerAttribute(string databaseName, string overridenCollectionName)
{
if (string.IsNullOrWhiteSpace(databaseName))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ internal string ResolveConnectionString(string unresolvedConnectionString, strin
private ChangeFeedHostOptions ResolveLeaseOptions(CosmosStoreTriggerAttribute attribute)
{
var leasesOptions = _bindingOptions.LeaseOptions;

var entityType = typeof(T);
var triggerChangeFeedHostOptions = new ChangeFeedHostOptions
{
LeasePrefix = ResolveAttributeValue(attribute.LeaseCollectionPrefix) ?? leasesOptions.LeasePrefix,
LeasePrefix = ResolveAttributeValue(attribute.LeaseCollectionPrefix) ?? (entityType.UsesSharedCollection() ? $"{entityType.GetSharedCollectionName()}_{entityType.GetSharedCollectionEntityName()}_" : $"{entityType.GetCollectionName()}_"),
FeedPollDelay = ResolveTimeSpanFromMilliseconds(nameof(CosmosStoreTriggerAttribute.FeedPollDelay), leasesOptions.FeedPollDelay, attribute.FeedPollDelay),
LeaseAcquireInterval = ResolveTimeSpanFromMilliseconds(nameof(CosmosStoreTriggerAttribute.LeaseAcquireInterval), leasesOptions.LeaseAcquireInterval, attribute.LeaseAcquireInterval),
LeaseExpirationInterval = ResolveTimeSpanFromMilliseconds(nameof(CosmosStoreTriggerAttribute.LeaseExpirationInterval), leasesOptions.LeaseExpirationInterval, attribute.LeaseExpirationInterval),
Expand Down

0 comments on commit d48c5f2

Please sign in to comment.