private ChangeFeedProcessorOptions BuildProcessorOptions(CosmosStoreTriggerAttribute attribute) { var leasesOptions = _bindingOptions.LeaseOptions; var entityType = typeof(T); var processorOptions = new ChangeFeedProcessorOptions { 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), LeaseRenewInterval = ResolveTimeSpanFromMilliseconds(nameof(CosmosStoreTriggerAttribute.LeaseRenewInterval), leasesOptions.LeaseRenewInterval, attribute.LeaseRenewInterval), CheckpointFrequency = leasesOptions.CheckpointFrequency ?? new CheckpointFrequency() }; if (attribute.CheckpointInterval > 0) { processorOptions.CheckpointFrequency.TimeInterval = TimeSpan.FromMilliseconds(attribute.CheckpointInterval); } if (attribute.CheckpointDocumentCount > 0) { processorOptions.CheckpointFrequency.ProcessedDocumentCount = attribute.CheckpointDocumentCount; } return(processorOptions); }
private string GetMonitoredCollectionName(CosmosStoreTriggerAttribute attribute) { if (!string.IsNullOrEmpty(ResolveAttributeValue(attribute.CollectionName))) { return(ResolveAttributeValue(attribute.CollectionName)); } var entityType = typeof(T); var isSharedCollection = entityType.UsesSharedCollection(); return(isSharedCollection ? entityType.GetSharedCollectionName() : entityType.GetCollectionName()); }
private string ResolveAttributeLeasesConnectionString(CosmosStoreTriggerAttribute attribute) { // If the lease connection string is not set, use the trigger's var connectionString = !string.IsNullOrEmpty(attribute.LeaseConnectionStringSetting) ? ResolveConnectionString(attribute.LeaseConnectionStringSetting, nameof(CosmosStoreTriggerAttribute.LeaseConnectionStringSetting)) : ResolveConnectionString(attribute.ConnectionStringSetting, nameof(CosmosStoreTriggerAttribute.ConnectionStringSetting)); if (string.IsNullOrEmpty(connectionString)) { ThrowMissingConnectionStringExceptionForLease(); } return(connectionString); }