Skip to content

Commit

Permalink
Merge pull request #1323 from ankurcharan/master
Browse files Browse the repository at this point in the history
add cosmos mi
  • Loading branch information
danielgerlag authored Jan 2, 2025
2 parents 746bb65 + ef17734 commit b26ab10
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
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

0 comments on commit b26ab10

Please sign in to comment.