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.
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() }
Use as follows:
if (ApplicationSwitches.mySwitch.enabled) {
// do something
}
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
.)