Skip to content

.Net MEVD: Dependency Injection #12097

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

Merged
merged 10 commits into from
May 16, 2025

Conversation

adamsitnik
Copy link
Member

These are all the missing connectors.

Fixes #10549

@adamsitnik adamsitnik requested a review from a team as a code owner May 15, 2025 20:42
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel memory labels May 15, 2025
Comment on lines +58 to +59
Func<IServiceProvider, SearchIndexClient>? clientProvider = default,
Func<IServiceProvider, AzureAISearchVectorStoreOptions>? optionsProvider = default,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the most flexible overload: the user can read anything form the service provider to create SearchIndexClient and/or AzureAISearchVectorStoreOptions or do nothing and we are going to try to resolve it from the DI

public static IServiceCollection AddAzureAISearchVectorStore(
this IServiceCollection services,
Uri endpoint,
AzureKeyCredential keyCredential,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, but using AzureKeyCredential rather than TokenCredential (I kept it for backward copat and ease of use)

{
Endpoint = endpoint,
ApiKey = apiKey
};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far, we had an overload that was taking an optional HttpClient and WeaviateVectorStoreOptions:

HttpClient? httpClient = default,
WeaviateVectorStoreOptions? options = default,

And one of them was supposed to set the endpoint and api key. I decided to simplify it and just take the raw values here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is OK, someone can still provide an httpclient via the clientProvider overloads.

this IServiceCollection services,
object? serviceKey,
Uri endpoint,
string? apiKey,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This argument is nullable because for local testing, it can be null.
It's not optional, because I believe that it would be error prone for real-life scenarios (users missing the value in prod).


namespace RedisIntegrationTests.Support;

internal class FakeDatabase : IDatabase
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Redis API does not allow to get a database without connecting to the server first. I wanted to keep those tests work no matter what, so I decided to fake the IDatabase. I had no idea that this interface implements few hundreds of methods!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big deal, but also consider using Moq

@adamsitnik adamsitnik requested review from roji and westey-m May 15, 2025 20:57
@adamsitnik adamsitnik merged commit 35a7beb into microsoft:feature-vector-data-preb3 May 16, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel memory .NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants