dynamo-db-switches


License

License

GroupId

GroupId

com.gu
ArtifactId

ArtifactId

dynamo-db-switches_2.12
Last Version

Last Version

0.5.1
Release Date

Release Date

Type

Type

jar
Description

Description

dynamo-db-switches
dynamo-db-switches
Project URL

Project URL

https://github.com/guardian/dynamo-db-switches
Project Organization

Project Organization

com.gu
Source Code Management

Source Code Management

https://github.com/guardian/dynamo-db-switches

Download dynamo-db-switches_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/com.gu/dynamo-db-switches_2.12/ -->
<dependency>
    <groupId>com.gu</groupId>
    <artifactId>dynamo-db-switches_2.12</artifactId>
    <version>0.5.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.gu/dynamo-db-switches_2.12/
implementation 'com.gu:dynamo-db-switches_2.12:0.5.1'
// https://jarcasting.com/artifacts/com.gu/dynamo-db-switches_2.12/
implementation ("com.gu:dynamo-db-switches_2.12:0.5.1")
'com.gu:dynamo-db-switches_2.12:jar:0.5.1'
<dependency org="com.gu" name="dynamo-db-switches_2.12" rev="0.5.1">
  <artifact name="dynamo-db-switches_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.gu', module='dynamo-db-switches_2.12', version='0.5.1')
)
libraryDependencies += "com.gu" % "dynamo-db-switches_2.12" % "0.5.1"
[com.gu/dynamo-db-switches_2.12 "0.5.1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.8
com.amazonaws : aws-java-sdk jar 1.10.28
org.clapper : grizzled-slf4j_2.12 jar 1.3.0

test (1)

Group / Artifact Type Version
org.scalacheck : scalacheck_2.12 jar 1.12.6

Project Modules

There are no modules declared in this project.

Dynamo DB Feature Switches

Feature switches in Dynamo DB.

Usage

Schema

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)
}

Updates

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
}

Copyright

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

com.gu

The Guardian

The source code of the world's leading liberal voice

Versions

Version
0.5.1