Skip to content

refactor: provider-refactor#792

Draft
knutties wants to merge 5 commits intomainfrom
provider-refactor-v1
Draft

refactor: provider-refactor#792
knutties wants to merge 5 commits intomainfrom
provider-refactor-v1

Conversation

@knutties
Copy link
Collaborator

Problem

Describe the problem you are trying to solve here

Solution

Provide a brief summary of your solution so that reviewers can understand your code

Environment variable changes

What ENVs need to be added or changed

Pre-deployment activity

Things needed to be done before deploying this change (if any)

Post-deployment activity

Things needed to be done after deploying this change (if any)

API changes

Endpoint Method Request body Response Body
API GET/POST, etc request response

Possible Issues in the future

Describe any possible issues that could occur because of this change

@semanticdiff-com
Copy link

semanticdiff-com bot commented Dec 18, 2025

@knutties knutties changed the title Provider refactor v1 refactor: provider-refactor Dec 18, 2025
/// Resolve all features for the given evaluation context
///
/// Returns a map of all feature keys to their resolved values
async fn resolve_all_features(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

resolve_all suffices ? To avoid confusion between config or features.

/// This trait provides methods to get information about experiments
/// and which variants are applicable for a given context.
#[async_trait]
pub trait FeatureExperimentMeta: Send + Sync {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should this be called FeatureExperimentMetaProvider ?

#[async_trait]
pub trait SuperpositionDataSource: Send + Sync {
/// Fetch the latest configuration from the data source
async fn fetch_config(&self) -> Result<ConfigData>;
Copy link
Collaborator Author

@knutties knutties Feb 13, 2026

Choose a reason for hiding this comment

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

Do we need a Context and Prefix Filter support here ?

Copy link
Collaborator Author

@knutties knutties Feb 13, 2026

Choose a reason for hiding this comment

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

    async fn fetch_filtered_config(&self, context: Option<Map<String, Value>, prefix_filter: Option<&[String]>,) -> Result<ConfigData>;

/// Fetch experiment data from the data source
///
/// Returns None if the data source doesn't support experiments
async fn fetch_experiments(&self) -> Result<Option<ExperimentData>>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do we need a context filter version for this?

/// Fetch experiment data from the data source
///
/// Returns None if the data source doesn't support experiments
async fn fetch_experiments(&self) -> Result<Option<ExperimentData>>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
async fn fetch_experiments(&self) -> Result<Option<ExperimentData>>;
async fn fetch_active_experiments(&self) -> Result<Option<ExperimentData>>;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Add support for

async fn fetch_filtered_active_experiments(&self, context: Option<&EvaluationContext>, prefix_filter: Option<&[String]>) -> Result<Option<ExperimentData>>;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Introduce following instead of above:
fetch_candidate_experiments (partial match)
fetch_matching_experiments (exact match)
taking Map and Prefix as args.

async fn fetch_experiments(&self) -> Result<Option<ExperimentData>>;

/// Get a human-readable name for this data source
fn source_name(&self) -> &str;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

skip - add if needed.

fn supports_experiments(&self) -> bool;

/// Close and cleanup resources used by this data source
async fn close(&self) -> Result<()>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Check if needed.

) -> Result<Map<String, Value>>;

/// Get metadata about this provider
fn metadata(&self) -> &AllFeatureProviderMetadata;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

skip - not needed

#[async_trait]
pub trait AllFeatureProvider: Send + Sync {
/// Resolve all features for the given evaluation context
///
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Add a sugar function for

get_default

/// Resolve all features for the given evaluation context
///
/// Returns a map of all feature keys to their resolved values
async fn resolve_all_features(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Support generic type deserialization in these methods.

Check if it is no-op for Map<String, Value>.

///
/// This returns information about which experiments are active
/// and which variants have been selected for the given context.
async fn get_experiment_metadata(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
async fn get_experiment_metadata(
async fn get_satisfied_experiments(

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is already supported in datasource - remove from here.

///
/// Returns None if the experiment is not applicable for the given context
/// Returns Some(variant_id) if a variant was selected
async fn get_experiment_variant(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant