Skip to content

Commit

Permalink
add cosmos mi
Browse files Browse the repository at this point in the history
  • Loading branch information
ankurcharan committed Dec 30, 2024
1 parent 746bb65 commit ef17734
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 ef17734

Please sign in to comment.