Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added CosmosClientOptions to UseCosmosDbPersistence method and CosmosClientFactory constructor #1062

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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