Class FeatureFlagManager

java.lang.Object
io.github.projectunified.faststats.core.Feature
io.github.projectunified.faststats.featureflag.FeatureFlagManager

public final class FeatureFlagManager extends Feature
Feature Flag Manager that coordinates flag checks, opting in/out, caching, and TTL.
  • Constructor Details

    • FeatureFlagManager

      public FeatureFlagManager()
      Creates a new FeatureFlagManager.
  • Method Details

    • getTtl

      public Duration getTtl()
      Get the TTL for the cached flag values.
      Returns:
      the TTL duration
    • ttl

      public FeatureFlagManager ttl(Duration ttl)
      Set the TTL for the cached flag values.
      Parameters:
      ttl - the TTL duration
      Returns:
      this manager instance
    • getAttributes

      public Map<String,Object> getAttributes()
      Returns the global error context attributes configured for this manager.
      Returns:
      the global error context attributes
    • attributes

      public FeatureFlagManager attributes(Consumer<Map<String,Object>> consumer)
      Modifies the global error context attributes using a consumer.
      Parameters:
      consumer - the consumer to modify attributes
      Returns:
      this manager instance
    • attributes

      public FeatureFlagManager attributes(Supplier<Map<String,Object>> supplier)
      Sets the global error context attributes using a supplier.
      Parameters:
      supplier - the supplier of attributes
      Returns:
      this manager instance
    • define

      public FeatureFlag<Boolean> define(String id, boolean defaultValue)
      Defines a boolean feature flag.
      Parameters:
      id - the flag id
      defaultValue - the default value
      Returns:
      a new FeatureFlag
    • define

      public FeatureFlag<Boolean> define(String id, boolean defaultValue, Map<String,Object> attributes)
      Defines a boolean feature flag with attributes.
      Parameters:
      id - the flag id
      defaultValue - the default value
      attributes - the attributes
      Returns:
      a new FeatureFlag
    • define

      public FeatureFlag<String> define(String id, String defaultValue)
      Defines a String feature flag.
      Parameters:
      id - the flag id
      defaultValue - the default value
      Returns:
      a new FeatureFlag
    • define

      public FeatureFlag<String> define(String id, String defaultValue, Map<String,Object> attributes)
      Defines a String feature flag with attributes.
      Parameters:
      id - the flag id
      defaultValue - the default value
      attributes - the attributes
      Returns:
      a new FeatureFlag
    • define

      public FeatureFlag<Number> define(String id, Number defaultValue)
      Defines a Number feature flag.
      Parameters:
      id - the flag id
      defaultValue - the default value
      Returns:
      a new FeatureFlag
    • define

      public FeatureFlag<Number> define(String id, Number defaultValue, Map<String,Object> attributes)
      Defines a Number feature flag with attributes.
      Parameters:
      id - the flag id
      defaultValue - the default value
      attributes - the attributes
      Returns:
      a new FeatureFlag
    • fetch

      public <T> CompletableFuture<T> fetch(FeatureFlag<T> flag)
    • optIn

      public <T> CompletableFuture<T> optIn(FeatureFlag<T> flag)
    • optOut

      public <T> CompletableFuture<T> optOut(FeatureFlag<T> flag)