Skip to content
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

feat: make feature flags a bit more granular #90

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jeroenptrs
Copy link

Purpose

Seeing the feature flag configuration was nice but it appeared to be a bit incomplete (for example, websockets has a feature flag but it's not configured or in use), so getFeature is now a reusable function to a certain degree and more parts/plugins are added to the list of flags.

This change also allows you to turn on / off plugins without having to remove code, mostly from the perspective of not wanting to cause too many changes that could cause merge conflicts.

I left the default values in the configuration as I didn't want to act too opinionated.

Additionally, I thought about switching to a comma separated list or an array of values, but ultimately felt like that was way more cumbersome to validate. As a tradeoff, this does inflate the amount of variables present in env vars a bit.

Tasks

  • use getFeature everywhere feature flags are used (and extract it to utils)
  • update tests
  • if a feature flag impacts a plugin, also prevent instantiating said plugin
  • add studio / interface / cron / cdc to feature flags as well

Verify

  • using Studio as an example, set ALLOW_STUDIO in wrangler to 0
  • launch starbasedb and go to your.url/studio
  • studio should no longer launch

@jeroenptrs jeroenptrs force-pushed the feat/granular-feature-flags branch from 932f8b9 to 40a913d Compare February 25, 2025 08:05
@jeroenptrs
Copy link
Author

Alright I made some changes and filtering the plugins array for undefined values seems like a better design as opposed to wrapping everything in if statements :)

@jeroenptrs jeroenptrs force-pushed the feat/granular-feature-flags branch from 40a913d to a4e64bd Compare February 25, 2025 14:28
Comment on lines +34 to +37
studio?: boolean
cron?: boolean
cdc?: boolean
interface?: boolean
Copy link
Member

Choose a reason for hiding this comment

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

I'm still weighing in my head if we want all the modular plugins to be controllable through the wrangler.toml or not.

There are pros for not including all plugins in the array such as the bundler won't include imports that don't exist and keep the deploy size down. Also if users create their own internal plugins they don't necessarily have to be aware that it can be controlled in one of two spots (the plugins array by omission, or the wrangler file by a flag).

The pro for including all of them in the array course might be that it is easier to quickly toggle features by switching a bit in the wrangler.

Still going back and forth on this internally but wanted to put my initial "where my head is at" status here so you don't think I've forgotten about this contribution!

@jeroenptrs jeroenptrs force-pushed the feat/granular-feature-flags branch from f32fb4f to 8b2e2cc Compare February 27, 2025 15:48
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.

2 participants