-
Notifications
You must be signed in to change notification settings - Fork 518
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cosmos DB initialization logic to a new assembly (#3743)
* a)Changes done on existing Microsoft.Health.Fhir.CosmosDb Project 1.Icollectionupdater copied to Istoreprocedure in cosmos db old project 2.older Istoreprocedure logic moved to new project with filename IStoredProcedureInstaller 3.StoredProcedureInstaller.cs removed from old db(Microsoft.Health.Fhir.CosmosDb) and moved this logic to new project with filename DataPlaneStoredProcedureInstaller.cs 4.Configs folder contains classes like CosmosDataStoreConfiguration,CosmosCollectionConfiguration moved to Microsoft.Health.Fhir.CosmosDb.Core project 5.Following classes moved to Microsoft.Health.Fhir.CosmosDb.Core project -SystemData -KnownDocumentProperties -ICollectionUpdater -CollectionVersion -CollectionUpgradeManager -IUpgradeManager -CollectionInitializer : we have removed depenedancy for RetryExceptionPolicyFactory in constructor -ICollectionInitializer -CosmosClientExtensions -ICosmosDbDistributedLock -ICosmosDbDistributedLockFactory -ICosmosClientTestProvider 6. Following existing Classes/interfaces modified -ICosmosClientInitializer -FhirCosmosClientInitializer -CosmosDbFhirStorageTestsFixture // TODO: TODO: need modify this class to call new CosmosDB .Initialization functions // now some existing call are commented -CosmosContainerProvider // TODO: TODO: need modify this class to call new CosmosDB .Initialization functions // now some existing call are commented b) New Microsoft.Health.Fhir.CosmosDb.Initialization project added -Initialization of cosmos DB functionality moved here - Moved Storeprocedure installation logic here Added classes like DataPlaneStoredProcedureInstaller,StoredProcedureMetadataBase - Also we have DataPlaneCollectionSetup class which will implement following methods -CreateDatabaseAsync - CreateCollection -UpdateFhirCollectionSettings c)Unit Test Project Added Microsoft.Health.Fhir.CosmosDb.Initialization.UnitTests project d)Also Added Microsoft.Health.Fhir.CosmosDb.Core project - We have moved common functionalities from Microsoft.Health.Fhir.CosmosDb project #User Story 112343: [Cosmos][OSS] Move Cosmos DB initialization logic to a new assembly * versions updated for some packages * Moved to CosmosDB.Core -StoredProcedureBase -IStoredProcedure -IStoredProcedureMetadata -StoredProcedureMetadata Moved to CosmosDB.Initialization: -UpdateUnsupportedSearchParameters -FhirCollectionSettingsUpdater * 1. Added ICollectionDataUpdater interface in cosmosdb project 2.Replaced ICollectionUpdater with ICollectionDataUpdater in CosmosDbSearchParameterStatusInitializer 3.moved else part logic from FhirCollectionSettingsUpdater to CosmosDbSearchParameterStatusInitializer 4.FhirCollectionSettingsUpdater is removed from solution * worked on code review comments * worked on review comments and cleaned up code * done with end to end flow testing with CosmosDbFhirStorageTestsFixture class * resolved installed storeprocedure issue * Unit test cases updated . DataPlaneCosmosDbRegistarionExtensions issue is resolved * resolved build issue for hardDelete * identity package updated to latest version to solve vulnerability issue * Solve the test failures in PR Disconnect ICollectionSetup from CosmosClient and Container. * fixed review comments * solved issues with unit test * Added new project refrences to docker file * updated docker file * removed extra call to fhircollectionsetting updater * Refactoring to avoid circle dependency (#3877) * merging refatoring changes with local branch * solved merge issues * fixes namespace issue for Core.Resources * resolves unit test issue for FHIRCosmosClientInitializer * Resolves unite test issues * added missing decorators on DataPlaneCollectionSetupTests * work on review comments * Adds classification attibutes * -Adding newly added project references to R4.slnf and R5.slnf -Adding simple threadsafe logic for creating CosmosClient instance * refactoring CreateCosmosClient logic to have validation logic --------- Co-authored-by: Fernando Henrique Inocêncio Borba Ferreira <[email protected]>
- Loading branch information
1 parent
ec9f656
commit 6f07bfc
Showing
87 changed files
with
1,076 additions
and
368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
namespace Microsoft.Health.Fhir.CosmosDb.Core | ||
{ | ||
public static class Constants | ||
{ | ||
public const string CollectionConfigurationName = "fhirCosmosDb"; | ||
public const string RawResource = "rawResource"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/Microsoft.Health.Fhir.CosmosDb.Core/Features/Storage/ICollectionSetup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Polly; | ||
|
||
namespace Microsoft.Health.Fhir.CosmosDb.Core.Features.Storage | ||
{ | ||
public interface ICollectionSetup | ||
{ | ||
public Task CreateDatabaseAsync(AsyncPolicy retryPolicy, CancellationToken cancellationToken); | ||
|
||
public Task CreateCollectionAsync(IEnumerable<ICollectionInitializer> collectionInitializers, AsyncPolicy retryPolicy, CancellationToken cancellationToken = default); | ||
|
||
public Task UpdateFhirCollectionSettingsAsync(CancellationToken cancellationToken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/Microsoft.Health.Fhir.CosmosDb.Core/Features/Storage/StoreProcedures/IStoredProcedure.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. | ||
// ------------------------------------------------------------------------------------------------- | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Azure.Cosmos.Scripts; | ||
|
||
namespace Microsoft.Health.Fhir.CosmosDb.Core.Features.Storage.StoredProcedures | ||
{ | ||
public interface IStoredProcedure | ||
{ | ||
Task<StoredProcedureExecuteResponse<T>> ExecuteStoredProcAsync<T>(Scripts client, string partitionId, CancellationToken cancellationToken, params object[] parameters); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...t.Health.Fhir.CosmosDb.Core/Features/Storage/StoreProcedures/IStoredProcedureInstaller.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Azure.Cosmos; | ||
|
||
namespace Microsoft.Health.Fhir.CosmosDb.Core.Features.Storage.StoredProcedures | ||
{ | ||
public interface IStoredProcedureInstaller | ||
{ | ||
Task ExecuteAsync(Container container, CancellationToken cancellationToken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...crosoft.Health.Fhir.CosmosDb.Core/Features/Storage/StoreProcedures/StoredProcedureBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using EnsureThat; | ||
using Microsoft.Azure.Cosmos; | ||
using Microsoft.Azure.Cosmos.Scripts; | ||
using Microsoft.Health.Core.Extensions; | ||
|
||
namespace Microsoft.Health.Fhir.CosmosDb.Core.Features.Storage.StoredProcedures | ||
{ | ||
public abstract class StoredProcedureBase : IStoredProcedure | ||
{ | ||
private readonly IStoredProcedureMetadata _storedProcedureMetadata; | ||
|
||
protected StoredProcedureBase(IStoredProcedureMetadata storedProcedureMetadata) | ||
{ | ||
EnsureArg.IsNotNull(storedProcedureMetadata, nameof(storedProcedureMetadata)); | ||
|
||
_storedProcedureMetadata = storedProcedureMetadata; | ||
} | ||
|
||
public string FullName => _storedProcedureMetadata.FullName; | ||
|
||
public async Task<StoredProcedureExecuteResponse<T>> ExecuteStoredProcAsync<T>(Scripts client, string partitionId, CancellationToken cancellationToken, params object[] parameters) | ||
{ | ||
EnsureArg.IsNotNull(client, nameof(client)); | ||
EnsureArg.IsNotNull(partitionId, nameof(partitionId)); | ||
|
||
StoredProcedureExecuteResponse<T> results = await client.ExecuteStoredProcedureAsync<T>( | ||
FullName, | ||
new PartitionKey(partitionId), | ||
parameters, | ||
cancellationToken: cancellationToken); | ||
|
||
return results; | ||
} | ||
} | ||
} |
Oops, something went wrong.