https://github.com/alvarolorentedev/scala-local-toggle
  
  
    feature toggle by configuration file for scala applications 
    https://github.com/alvarolorentedev/scala-local-toggle
  
feature-flags feature-toggle feature-toggles toggle
        Last synced: 5 months ago 
        JSON representation
    
feature toggle by configuration file for scala applications
- Host: GitHub
- URL: https://github.com/alvarolorentedev/scala-local-toggle
- Owner: alvarolorentedev
- License: mit
- Created: 2017-10-31T12:28:28.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-06T08:00:36.000Z (almost 8 years ago)
- Last Synced: 2025-02-22T13:44:12.955Z (8 months ago)
- Topics: feature-flags, feature-toggle, feature-toggles, toggle
- Language: Scala
- Size: 59.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
- 
            Metadata Files:
            - Readme: README.md
- License: LICENSE
 
Awesome Lists containing this project
README
          # 
[](https://travis-ci.org/kanekotic/scala-local-toggle)
[](https://maven-badges.herokuapp.com/maven-central/com.github.kanekotic/scala-local-toggle_2.12/badge.svg?style=flat)
feature toggle by configuration file for scala applications
## Install
```scala
//Use version in badge
libraryDependencies += "com.github.kanekotic" %% "scala-local-toggle" % 
```
##Use
1. Instantiate can be done by newing the class, it can also be register in guice or dependency injection frameworks.
```scala
  val toggle = new ToggleManager();
``` 
2. 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:
```hocon
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
```hocon
  feature.local.environment: "SOME_ENVIROMENT_VARIABLE_NAME"
  #Defaults to ENVIRONMENT 
``` 
3. Use with the name identifier defined in the previous step
```scala
  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