guardian / dynamo-db-switches   0.6.6


Dynamo DB feature switches

Scala versions: 2.13 2.12

Dynamo DB Feature Switches

dynamo-db-switches Scala version support

Feature switches in Dynamo DB.



Create a DynamoDB table called 'featureSwitches' with the following schema:

| Hash key (String) | Number        |
| name              | enabled       |

Set enabled to 1 to enable the feature switch, 0 to disable it.

Switch instantiation

Define your switches in an object

object ApplicationSwitches extends Switches {
  val dynamoDbClient = // define your dynamo DB client here

  val mySwitch = Switch("nameOfSwitch", default = false)

  // make sure you put all switches in here or they won't update
  val all = List(mySwitch)


Use a scheduler to update the switches from Dynamo DB once per minute

Akka.scheduler.schedule(0.seconds, 1.minute) { ApplicationSwitches.update() }

Testing switches

Use as follows:

if (ApplicationSwitches.mySwitch.enabled) {
  // do something

Releasing builds

Releases are published to Sonatype OSS and synced to Maven Central. This is carried out automatically by the release GHA workflow whenever a PR is merged to main.


Copyright 2013 Guardian Media Group. Licensed under Apache 2.0. (See LICENSE.)