Class FeatureFlagManager
java.lang.Object
io.github.projectunified.faststats.core.Feature
io.github.projectunified.faststats.featureflag.FeatureFlagManager
Feature Flag Manager that coordinates flag checks, opting in/out, caching, and TTL.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionattributes(Consumer<Map<String, Object>> consumer) Modifies the global error context attributes using a consumer.attributes(Supplier<Map<String, Object>> supplier) Sets the global error context attributes using a supplier.Defines a boolean feature flag.Defines a boolean feature flag with attributes.Defines a Number feature flag.Defines a Number feature flag with attributes.Defines a String feature flag.Defines a String feature flag with attributes.<T> CompletableFuture<T> fetch(FeatureFlag<T> flag) Returns the global error context attributes configured for this manager.getTtl()Get the TTL for the cached flag values.<T> CompletableFuture<T> optIn(FeatureFlag<T> flag) <T> CompletableFuture<T> optOut(FeatureFlag<T> flag) Set the TTL for the cached flag values.Methods inherited from class Feature
deserialize, getDefaultContext, getDefaultProperties, getFeature, getProperty, getScheduler, onConfigMigrate, onShutdown, onStart, submit
-
Constructor Details
-
FeatureFlagManager
public FeatureFlagManager()Creates a new FeatureFlagManager.
-
-
Method Details
-
getTtl
-
ttl
Set the TTL for the cached flag values.- Parameters:
ttl- the TTL duration- Returns:
- this manager instance
-
getAttributes
-
attributes
Modifies the global error context attributes using a consumer.- Parameters:
consumer- the consumer to modify attributes- Returns:
- this manager instance
-
attributes
Sets the global error context attributes using a supplier.- Parameters:
supplier- the supplier of attributes- Returns:
- this manager instance
-
define
Defines a boolean feature flag.- Parameters:
id- the flag iddefaultValue- the default value- Returns:
- a new FeatureFlag
-
define
-
define
Defines a String feature flag.- Parameters:
id- the flag iddefaultValue- the default value- Returns:
- a new FeatureFlag
-
define
-
define
Defines a Number feature flag.- Parameters:
id- the flag iddefaultValue- the default value- Returns:
- a new FeatureFlag
-
define
-
fetch
-
optIn
-
optOut
-