scala-local-toggle


License

License

MIT
Categories

Categories

Scala Languages
GroupId

GroupId

com.github.kanekotic
ArtifactId

ArtifactId

scala-local-toggle_2.12
Last Version

Last Version

0.0.28
Release Date

Release Date

Type

Type

jar
Description

Description

scala-local-toggle
scala-local-toggle
Project URL

Project URL

https://github.com/kanekotic/scala-local-toggle
Project Organization

Project Organization

com.github.kanekotic
Source Code Management

Source Code Management

https://github.com/kanekotic/scala-local-toggle

Download scala-local-toggle_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.kanekotic/scala-local-toggle_2.12/ -->
<dependency>
    <groupId>com.github.kanekotic</groupId>
    <artifactId>scala-local-toggle_2.12</artifactId>
    <version>0.0.28</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.kanekotic/scala-local-toggle_2.12/
implementation 'com.github.kanekotic:scala-local-toggle_2.12:0.0.28'
// https://jarcasting.com/artifacts/com.github.kanekotic/scala-local-toggle_2.12/
implementation ("com.github.kanekotic:scala-local-toggle_2.12:0.0.28")
'com.github.kanekotic:scala-local-toggle_2.12:jar:0.0.28'
<dependency org="com.github.kanekotic" name="scala-local-toggle_2.12" rev="0.0.28">
  <artifact name="scala-local-toggle_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.kanekotic', module='scala-local-toggle_2.12', version='0.0.28')
)
libraryDependencies += "com.github.kanekotic" % "scala-local-toggle_2.12" % "0.0.28"
[com.github.kanekotic/scala-local-toggle_2.12 "0.0.28"]

Dependencies

compile (2)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.3
com.github.pureconfig : pureconfig_2.12 jar 0.8.0

test (2)

Group / Artifact Type Version
org.scalatest : scalatest_2.12 jar 3.0.4
org.mockito : mockito-core jar 2.10.0

Project Modules

There are no modules declared in this project.

logomakr_6etktj

Build Status Maven Status

feature toggle by configuration file for scala applications

Install

//Use version in badge
libraryDependencies += "com.github.kanekotic" %% "scala-local-toggle" % <version>

##Use

  1. Instantiate can be done by newing the class, it can also be register in guice or dependency injection frameworks.
  val toggle = new ToggleManager();
  1. use default files for loading configuration, it will try to load toggles from the following (first-listed are higher priority):
  • system properties
  • application.conf (all resources on classpath with this name)
  • application.json (all resources on classpath with this name)
  • application.properties (all resources on classpath with this name)
  • reference.conf (all resources on classpath with this name)

this files will require to have an setting for the toggles HOCON or JSON complient configuration similar to this, in any other case toggles will default to false:

feature.local.toggles: [
    {
      "name": "NAME_OF_YOUR_TOGGLE",
      "local": true
      "development": true
      "production": false
    }, 
    {
      "name": "NAME_OF_OTHER_YOUR_TOGGLE",
      "local": true
      "development": false
      "production": false
    }
  ]

the boolean denotes the state of the toggle depending on the environment, and the name is the identifying the value of the environment variable:

  • local maps to environment variable value LOCAL.
  • development maps to environment variable value DEVELOPMENT.
  • production maps to environment variable value PRODUCTION.

aditionally the enviroment variable that will be track to know the current environment of execution can be modified by

  feature.local.environment: "SOME_ENVIROMENT_VARIABLE_NAME"
  #Defaults to ENVIRONMENT 
  1. Use with the name identifier defined in the previous step
  if (toggle.isEnabled("NAME_OF_YOUR_TOGGLE")) {
    //your code under toggle here
  }

LOGO

Check out the new logo that I created on LogoMakr.com https://logomakr.com/6ETKtj

Versions

Version
0.0.28
0.0.25
0.0.23
0.0.22