revert AI some suggestions for they break if search index initially does not exist#350
Open
revert AI some suggestions for they break if search index initially does not exist#350
Conversation
Contributor
Reviewer's Guide by SourceryThis PR reverts some AI suggestions that caused breaks if the search index did not initially exist. It modifies the Azure Cognitive Search implementation to handle missing indexes more gracefully and updates the InfrastructureServicesBuilder to initialize search clients asynchronously. Sequence diagram for updated Azure Cognitive Search initializationsequenceDiagram
participant App
participant Builder as InfrastructureServicesBuilder
participant Search as AzCognitiveSearch
participant Azure as Azure Services
App->>Builder: initialize()
activate Builder
Builder->>Search: new AzCognitiveSearch(endpoint)
activate Search
Search->>Azure: create DefaultAzureCredential
Search->>Azure: create SearchIndexClient
Search-->>Builder: return instance
deactivate Search
Builder->>Search: initializeSearchClients()
activate Search
Search->>Azure: listIndexesNames()
Azure-->>Search: existing indexes
loop For each index
Search->>Search: set searchClient in Map
end
Search-->>Builder: void
deactivate Search
Builder-->>App: void
deactivate Builder
Class diagram for updated Cognitive Search interfacesclassDiagram
class CognitiveSearchBase {
<<interface>>
+createIndex(indexDefinition: SearchIndex)
+createOrUpdateIndex(indexName: string, indexDefinition: SearchIndex)
+search(indexName: string, searchText: string, options?: any)
+deleteDocument(indexName: string, document: any)
+indexDocument(indexName: string, document: any)
+deleteIndex(indexName: string)
+indexExists(indexName: string) boolean
+initializeSearchClients() Promise~void~
}
class AzCognitiveSearch {
-client: SearchIndexClient
-searchClients: Map
+constructor(endpoint: string)
+initializeSearchClients()
+indexExists(indexName: string)
+createIndex(indexDefinition: SearchIndex)
+search(indexName: string, searchText: string, options?: any)
}
CognitiveSearchBase <|.. AzCognitiveSearch
note for AzCognitiveSearch "Modified to handle missing indexes
and initialize clients asynchronously"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey @nguyenduy - I've reviewed your changes - here's some feedback:
Overall Comments:
- The change from async indexExists() to sync indexExists() is a breaking change that could affect existing code. Consider either keeping the async version for backward compatibility or documenting this change prominently for users of the library.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Review instructions: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
gp |
|
diff |
Nwachimereze1-hub
approved these changes
Dec 20, 2024
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Initialize search clients during application startup to ensure they are available when needed.
Bug Fixes:
Enhancements: