Skip to content

Commit

Permalink
Merge pull request #1062 from afroze9/master
Browse files Browse the repository at this point in the history
Added CosmosClientOptions to UseCosmosDbPersistence method and CosmosClientFactory constructor
  • Loading branch information
danielgerlag authored Aug 2, 2024
2 parents 4f085d1 + e0107a0 commit 470987d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<ICosmosClientFactory>(sp => new CosmosClientFactory(connectionString));
options.Services.AddSingleton<ICosmosClientFactory>(sp => new CosmosClientFactory(connectionString, clientOptions));
options.Services.AddTransient<ICosmosDbProvisioner>(sp => new CosmosDbProvisioner(sp.GetService<ICosmosClientFactory>(), cosmosDbStorageOptions));
options.Services.AddSingleton<IWorkflowPurger>(sp => new WorkflowPurger(sp.GetService<ICosmosClientFactory>(), databaseId, cosmosDbStorageOptions));
options.UsePersistence(sp => new CosmosDbPersistenceProvider(sp.GetService<ICosmosClientFactory>(), databaseId, sp.GetService<ICosmosDbProvisioner>(), cosmosDbStorageOptions));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 470987d

Please sign in to comment.