Skip to content

feat: Utility class to produce IConfigurationWire instances#241

Merged
typotter merged 11 commits intomainfrom
typo/config-wire-helper
Mar 13, 2025
Merged

feat: Utility class to produce IConfigurationWire instances#241
typotter merged 11 commits intomainfrom
typo/config-wire-helper

Conversation

@typotter
Copy link
Copy Markdown
Collaborator

@typotter typotter commented Mar 12, 2025

Towards FF-4076
Stacked on #240

Motivation and Context

The gen2 offline init (aka, bootstrap) requires an IConfigurationWire payload (instead of just the flag UFC json, which does not contain bandits).
Users of this bootstrap api will need to be able to generate the payload.

Description

  • gather config-wire code into a subdir
  • ConfigurationWireHelper class to fetch configs from the Eppo API endpoints and re-encode them as an IConfigurationWire instance

How has this been tested?

  • Tests

Copy link
Copy Markdown
Contributor

@aarsilv aarsilv left a comment

Choose a reason for hiding this comment

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

I like everything but the names! Naming is hard...

// This SDK causes the cloud endpoint below to serve the UFC test file with bandit flags.
const BANDIT_SDK_KEY = 'this-key-serves-bandits';

describe('ConfigurationWireHelper', () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🙌

Comment thread src/configuration-wire/configuration-wire-helper.ts Outdated
Base automatically changed from tp/ufc-in-config-wire to main March 13, 2025 14:57
@typotter typotter merged commit c2c7937 into main Mar 13, 2025
@typotter typotter deleted the typo/config-wire-helper branch March 13, 2025 15:18
*/
public static build(
sdkKey: string,
opts: SdkOptions = { sdkName: 'android', sdkVersion: '4.0.0' },
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is there any reason we're choosing these values for defaults? They seem extremely off from being default

* Fetches configuration data from the API and build a Bootstrap Configuration (aka an `IConfigurationWire` object).
* The IConfigurationWire instance can be used to bootstrap some SDKs.
*/
public async fetchBootstrapConfiguration(): Promise<IConfigurationWire> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Any reason we're calling it "bootstrap configuration" vs just "configuration"?

When I head "bootstrap configuration" I imagine: sdk key and set of urls to fetch configuration from

/**
* Helper class for fetching and converting configuration from the Eppo API(s).
*/
export class ConfigurationWireHelper {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks extremely similar to configuration fetcher. Is there a significant difference? can this be just a new configuration fetcher?


if (!configResponse?.flags) {
console.warn('Unable to fetch configuration, returning empty configuration');
return Promise.resolve(ConfigurationWireV1.empty());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

minor: given the function is async, I'm pretty sure you can just do this here:

return ConfigurationWireV1.empty();

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.

3 participants