Skip to content

Instantly share code, notes, and snippets.

@ggemre
Created November 1, 2023 15:48
Show Gist options
  • Save ggemre/798ade6749c20eb0350f133ee679689f to your computer and use it in GitHub Desktop.
Save ggemre/798ade6749c20eb0350f133ee679689f to your computer and use it in GitHub Desktop.
Feature Flag Investigation

Using feature flags for persons/bdp updates

As an alternative to branching, switching applications over to use persons v4 and BDPs can be cleanly cut over via feature flags:

Possible implementations

1. environment variables

Services being called are conditionally controlled with environment variables. Switching flags is as easy as updating a variable but requires a redeployment.

Example implementation:

USE_BDP=true
if (USE_BDP) {
	// get data new way
} else {
	// use old implementation
}

2. config file

Use a single config file with every feature flag contained within. Import that file to access certain flags.

{
	"bdp": true
}
flags = require('./app/config/flags.json')

if (flags.bdp) {
	// get data new way
} else {
	// use old implementation
}

3. use 3rd party feature flag service

Toggle feature flags in real time via api provided by our service or 3rd party service. Centralized, but huge overhead.

Quick POC

Possible Vue example (snippet from email alias manager)

<template>
  <div>
    <!-- <h2>Admin Functions: </h2> -->
    <div v-if="namesearch">
      <h2>Proxy Search by Person: &nbsp;</h2>
      <br>
      <byu-person-lookup
          @byu-lookup-results-select="found_person"
          id="person_navigation"
          context="admin">
        <byu-personsv4-datasource v-if="PERSONS_V4"></byu-personsv4-datasource>
        <byu-personsv3-datasource v-else></byu-personsv3-datasource>
      </byu-person-lookup>
    </div>
</template>

Transitioning these endpoints using feature flags allows us to commit the necessary changes without changing anything for the production application. Instead of the changes sitting in a separate branch until March, (which could get forgotten or outdated), we can commit the changes now and test that they work by simply changing an environment variable/config property locally while being certain that the transitioned changes will remain compatible as the application is maintained for next few months.

Possible steps:

  1. Add new endpoints that are toggled behind a feature flag, add the feature flags using one of the methods above.
  2. Test that it works locally, leave the flag with the old endpoints until March
  3. When it's time to transition, update the flag and ensure everything works exactly the same
  4. Remove the old endpoints and feature flags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment