All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gu.featureswitching.InMemoryFeatureSwitchEnablingStrategy.scala Maven / Gradle / Ivy

package com.gu.featureswitching

import collection.mutable.LinkedHashMap

// Simple in-memory implementation of feature state persistence.
// Obviously, don't use this if you have multiple app servers!
trait InMemoryFeatureSwitchEnablingStrategy extends FeatureSwitchingEnablingStrategy {
  var persistence: LinkedHashMap[FeatureSwitch, Boolean] = new LinkedHashMap[FeatureSwitch, Boolean]()

  def featureIsEnabled(feature: FeatureSwitch): Option[Boolean] = {
    persistence.get(feature)
  }

  def featureSetEnabled(feature: FeatureSwitch, enabled: Boolean) {
    persistence(feature) = enabled
  }

  def featureResetEnabled(feature: FeatureSwitch) {
    persistence.remove(feature)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy