Открыть меню
Открыть персональное меню
Вы не представились системе
Your IP address will be publicly visible if you make any edits.

Модуль:FeatureFlag/doc

Материал из wiki.iccup.org

Это страница документации Модуль:FeatureFlag.


FeatureFlag Module Documentation[править код]

The `FeatureFlag` module is used to manage feature flags, which are boolean values controlling whether certain code paths related to new features are enabled or not. This module provides functionality to read, set, and temporarily apply feature flags.

Usage[править код]

Feature flags can be used to enable or disable specific features or parts of code. They can be set permanently or temporarily for a specific scope. This is useful for enabling experimental features, rolling out new functionalities gradually, or toggling features for debugging purposes.

Example Usage[править код]

To get the value of a feature flag: -- Get the current value of a feature flag local isEnabled = FeatureFlag.get('chiseled_face')

To set the value of a feature flag: -- Set a feature flag to true FeatureFlag.set('thick_mustache', true)

To apply feature flags temporarily inside a specific function scope: -- Temporarily set feature flags FeatureFlag.with({rugged_grin = true}, function()

   -- Code executed with the feature flag set

end)

API[править код]

Программное имя: FeatureFlag


get (flag: string) → boolean

Retrieves the boolean value of a feature flag. Returns the default value if the flag has not been set.


{{#iccupdb_datapoint:API_FeatureFlag/doc_get

     |type=api
     |name=get
     |information=
     |image=
     |date=
     |extradata={{#iccupdb_create_json:
       |description=Retrieves the boolean value of a feature flag. Returns the default value if the flag has not been set.
       |params=flag: string
       |returns=boolean
       |module=Module:FeatureFlag
     }}
   }}


set (flag: string, value: boolean?) → nil

Sets the value of a feature flag. If the value is nil, it resets the flag to its default value.


{{#iccupdb_datapoint:API_FeatureFlag/doc_set

     |type=api
     |name=set
     |information=
     |image=
     |date=
     |extradata={{#iccupdb_create_json:
       |description=Sets the value of a feature flag. If the value is nil, it resets the flag to its default value.
       |params=flag: string, value: boolean?
       |returns=nil
       |module=Module:FeatureFlag
     }}
   }}


with (flags: {[string]: boolean}, f: function) → Result of the function execution or an error

Temporarily sets feature flags inside the provided function scope. After execution, flags are restored to their previous values.


{{#iccupdb_datapoint:API_FeatureFlag/doc_with

     |type=api
     |name=with
     |information=
     |image=
     |date=
     |extradata={{#iccupdb_create_json:
       |description=Temporarily sets feature flags inside the provided function scope. After execution, flags are restored to their previous values.
       |params=flags: {[string]: boolean}, f: function
       |returns=Result of the function execution or an error
       |module=Module:FeatureFlag
     }}
   }}


getConfig (flag: string) → table containing the defaultValue

Retrieves the configuration for a specified feature flag, including its default value.


{{#iccupdb_datapoint:API_FeatureFlag/doc_getConfig

     |type=api
     |name=getConfig
     |information=
     |image=
     |date=
     |extradata={{#iccupdb_create_json:
       |description=Retrieves the configuration for a specified feature flag, including its default value.
       |params=flag: string
       |returns=table containing the defaultValue
       |module=Module:FeatureFlag
     }}
   }}


Посмотрите всю нашу документацию iCCup здесь.



Feature Flag Configuration[править код]

Feature flags are configured in `Module:FeatureFlag/Config`. Each flag should have an entry specifying its default value. When a flag is accessed for the first time, its value is read from this configuration.

Wikitext Integration[править код]

Feature flags are accessible in wikitext using the VariablesLua extension. Example usage in wikitext:


Notes[править код]

- Ensure that `Module:FeatureFlag/Config` contains all feature flags used in the code. - Feature flags should be used responsibly to control feature rollouts and testing scenarios.

See Also[править код]