From a9fb674056279c7351ed9fc7474c072359b5f504 Mon Sep 17 00:00:00 2001 From: afroze9 Date: Sun, 3 Jul 2022 07:55:42 +0500 Subject: [PATCH] Added CosmosClientOptions to UseCosmosDbPersistence method and CosmosClientFactory constructor. --- .../ServiceCollectionExtensions.cs | 8 +++++--- .../Services/CosmosClientFactory.cs | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/providers/WorkflowCore.Providers.Azure/ServiceCollectionExtensions.cs b/src/providers/WorkflowCore.Providers.Azure/ServiceCollectionExtensions.cs index 0aa1963e4..d6aec277d 100644 --- a/src/providers/WorkflowCore.Providers.Azure/ServiceCollectionExtensions.cs +++ b/src/providers/WorkflowCore.Providers.Azure/ServiceCollectionExtensions.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.Logging; +using Microsoft.Azure.Cosmos; +using Microsoft.Extensions.Logging; using WorkflowCore.Interface; using WorkflowCore.Models; using WorkflowCore.Providers.Azure.Interface; @@ -31,14 +32,15 @@ public static WorkflowOptions UseCosmosDbPersistence( this WorkflowOptions options, string connectionString, string databaseId, - CosmosDbStorageOptions cosmosDbStorageOptions = null) + CosmosDbStorageOptions cosmosDbStorageOptions = null, + CosmosClientOptions clientOptions = null) { if (cosmosDbStorageOptions == null) { cosmosDbStorageOptions = new CosmosDbStorageOptions(); } - options.Services.AddSingleton(sp => new CosmosClientFactory(connectionString)); + options.Services.AddSingleton(sp => new CosmosClientFactory(connectionString, clientOptions)); options.Services.AddTransient(sp => new CosmosDbProvisioner(sp.GetService(), cosmosDbStorageOptions)); options.Services.AddSingleton(sp => new WorkflowPurger(sp.GetService(), databaseId, cosmosDbStorageOptions)); options.UsePersistence(sp => new CosmosDbPersistenceProvider(sp.GetService(), databaseId, sp.GetService(), cosmosDbStorageOptions)); diff --git a/src/providers/WorkflowCore.Providers.Azure/Services/CosmosClientFactory.cs b/src/providers/WorkflowCore.Providers.Azure/Services/CosmosClientFactory.cs index 9cb4cc572..ac5dc7f4a 100644 --- a/src/providers/WorkflowCore.Providers.Azure/Services/CosmosClientFactory.cs +++ b/src/providers/WorkflowCore.Providers.Azure/Services/CosmosClientFactory.cs @@ -10,9 +10,9 @@ public class CosmosClientFactory : ICosmosClientFactory, IDisposable private CosmosClient _client; - public CosmosClientFactory(string connectionString) + public CosmosClientFactory(string connectionString, CosmosClientOptions clientOptions = null) { - _client = new CosmosClient(connectionString); + _client = new CosmosClient(connectionString, clientOptions); } public CosmosClient GetCosmosClient()