Skip to content

[FEATURE] Add Dependency Injection support to multi-provider #549

@askpt

Description

@askpt

Requirements

Add support for Dependency Injection to the multi-provider implementation, following the established pattern used by the InMemoryProvider.

Current State

The multi-provider currently requires manual instantiation of provider instances and ProviderEntry objects, as seen in the AspNetCore sample:

var provider1 = new InMemoryProvider(provider1Flags);
var provider2 = new InMemoryProvider(provider2Flags);
var providerEntries = new List<ProviderEntry>
{
    new ProviderEntry(provider1, "provider1"),
    new ProviderEntry(provider2, "provider2")
};
var multiProvider = new MultiProvider(providerEntries, new FirstMatchStrategy());

Desired State

Enable multi-provider configuration through DI container registration, similar to how InMemoryProvider supports DI through FeatureBuilderExtensions.AddInMemoryProvider(). This should allow:

services.AddOpenFeature()
    .AddMultiProvider(builder => builder
        .AddProvider<InMemoryProvider>("provider1", serviceProvider => /* configure */)
        .AddProvider<CustomProvider>("provider2")
        .UseStrategy<FirstMatchStrategy>()
    );

Implementation Requirements

  • Follow the same DI patterns established by src/OpenFeature.DependencyInjection/Providers/Memory/FeatureBuilderExtensions.cs
  • Support provider registration with optional names and configuration
  • Allow strategy selection through DI
  • Enable provider dependencies to be resolved from the DI container
  • Maintain compatibility with existing multi-provider constructor

This feature is currently blocked by issue #545.

Please ensure the design aligns with existing multi-provider architecture and is extensible for future use cases.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions