Skip to content

Arius.Core: Explicit dependency injection for ContainerNamesQueryHandler #44

@woutervanranst

Description

@woutervanranst

Explicit dependency injection for ContainerNamesQueryHandler.

The handler receives the entire IServiceProvider but only needs IBlobServiceFactory. Pass the factory explicitly instead, matching the pattern used by ListQueryHandler and ChunkHydrationStatusQueryHandler:

services.AddSingleton<IStreamQueryHandler<ContainerNamesQuery, string>>(sp =>
new ContainerNamesQueryHandler(
sp.GetRequiredService()));
Then update the handler constructor to ContainerNamesQueryHandler(IBlobServiceFactory blobServiceFactory). This makes dependencies explicit and testable.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @src/Arius.Core/ServiceCollectionExtensions.cs around lines 94 - 96, Replace
the anonymous factory that injects the whole IServiceProvider into the
ContainerNamesQueryHandler with an explicit dependency on IBlobServiceFactory:
update the registration of IStreamQueryHandler<ContainerNamesQuery, string> to
resolve sp.GetRequiredService() and pass that into the
handler, and change the ContainerNamesQueryHandler constructor signature to
ContainerNamesQueryHandler(IBlobServiceFactory blobServiceFactory) so the
handler only depends on IBlobServiceFactory (matching the pattern used by
ListQueryHandler and ChunkHydrationStatusQueryHandler) and is easier to unit
test.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions