dynamo-db-switches


License

License

GroupId

GroupId

com.gu
ArtifactId

ArtifactId

dynamo-db-switches_2.11
Last Version

Last Version

0.5
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.11

How to add to project

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

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.7
com.amazonaws : aws-java-sdk jar 1.10.28
org.clapper : grizzled-slf4j_2.11 jar 1.0.2

test (1)

Group / Artifact Type Version
org.scalacheck : scalacheck_2.11 jar 1.10.1

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
0.4.1