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

add cosmos mi #1323

Merged
merged 1 commit into from
Jan 2, 2025
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
Expand Up @@ -46,5 +46,24 @@ public static WorkflowOptions UseCosmosDbPersistence(
options.UsePersistence(sp => new CosmosDbPersistenceProvider(sp.GetService<ICosmosClientFactory>(), databaseId, sp.GetService<ICosmosDbProvisioner>(), cosmosDbStorageOptions));
return options;
}

public static WorkflowOptions UseCosmosDbPersistence(
this WorkflowOptions options,
CosmosClient client,
string databaseId,
CosmosDbStorageOptions cosmosDbStorageOptions = null,
CosmosClientOptions clientOptions = null)
{
if (cosmosDbStorageOptions == null)
{
cosmosDbStorageOptions = new CosmosDbStorageOptions();
}

options.Services.AddSingleton<ICosmosClientFactory>(sp => new CosmosClientFactory(client));
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));
return options;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public CosmosClientFactory(string connectionString, CosmosClientOptions clientOp
_client = new CosmosClient(connectionString, clientOptions);
}

public CosmosClientFactory(CosmosClient client)
{
_client = client;
}

public CosmosClient GetCosmosClient()
{
return this._client;
Expand Down
Loading