forge.featureflags¶
Feature flags with boolean, percentage rollout, and user-segment evaluation.
forge.featureflags ¶
Feature Flags module — boolean, percentage rollout, and user-segment evaluation.
Provides typed flag definitions, evaluation context, consistent-hash based percentage rollout, in-memory and Redis-backed storage, and CLI management.
Classes¶
EvaluationContext ¶
Bases: BaseModel
Contextual information used during flag evaluation.
Source code in src/forge/featureflags/models.py
EvaluationReason ¶
Bases: StrEnum
Reason why a flag evaluated to a particular value.
Source code in src/forge/featureflags/models.py
EvaluationResult ¶
Bases: BaseModel
Result of a single flag evaluation.
Source code in src/forge/featureflags/models.py
FeatureFlagError ¶
Bases: ForgeError
Base exception for all feature flag-related errors.
FeatureFlagsModule ¶
Bases: ForgeModule
Manages feature flag definitions, storage, and evaluation.
Supports boolean, percentage rollout, and user-segment based flag evaluation with in-memory and optional Redis backends.
Source code in src/forge/featureflags/module.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
Methods:¶
delete_flag
async
¶
evaluate
async
¶
Evaluate a single flag for the given context.
evaluate_all
async
¶
Evaluate all flags for the given context.
evaluate_bulk
async
¶
Evaluate multiple flags for the given context.
Source code in src/forge/featureflags/module.py
get_flag
async
¶
health_check ¶
Check the health status of the feature flags backend.
Source code in src/forge/featureflags/module.py
list_flags
async
¶
set_flag
async
¶
setup
async
¶
Initialize the feature flags module.
Source code in src/forge/featureflags/module.py
teardown
async
¶
Teardown the feature flags module.
Source code in src/forge/featureflags/module.py
FlagDefinition ¶
Bases: BaseModel
Definition of a single feature flag.
Source code in src/forge/featureflags/models.py
FlagEvaluationError ¶
Bases: FeatureFlagError
Raised when flag evaluation encounters an error.
FlagEvaluator ¶
Evaluates feature flags against an evaluation context.
Source code in src/forge/featureflags/evaluator.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
Methods:¶
evaluate
async
¶
Evaluate a single feature flag for the given context.
Source code in src/forge/featureflags/evaluator.py
evaluate_all
async
¶
Evaluate all stored feature flags for the given context.
Source code in src/forge/featureflags/evaluator.py
evaluate_bulk
async
¶
Evaluate multiple feature flags for the given context.
Source code in src/forge/featureflags/evaluator.py
FlagNotFoundError ¶
Bases: FeatureFlagError
Raised when a requested flag is not found in the store.
FlagRule ¶
Bases: BaseModel
An override rule for a feature flag.
Source code in src/forge/featureflags/models.py
FlagStoreError ¶
Bases: FeatureFlagError
Raised when a flag store operation fails.
FlagType ¶
InvalidFlagDefinitionError ¶
Bases: FeatureFlagError
Raised when a flag definition is invalid or malformed.
MemoryFlagStore ¶
In-memory flag store using a dict.
Source code in src/forge/featureflags/store.py
RedisFlagStore ¶
Redis-backed flag store using redis.asyncio.
Source code in src/forge/featureflags/store.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
SegmentRule ¶
Bases: BaseModel
A rule defining a user segment for flag targeting.