You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| ✅ |[Hooks](#hooks)| Add functionality to various stages of the flag evaluation life-cycle. |
110
110
| ❌ |[Tracking](#tracking)| Associate user actions with feature flag evaluations. |
111
111
| ❌ |[Logging](#logging)| Integrate with popular logging packages. |
112
-
|❌|[Named clients](#named-clients)| Utilize multiple providers in a single application. |
112
+
|✅|[MultiProvider](#multiprovider)| Utilize multiple providers in a single application. |
113
113
| ✅ |[Eventing](#eventing)| React to state changes in the provider or flag management system. |
114
114
| ❌ |[Shutdown](#shutdown)| Gracefully clean up a provider during application shutdown. |
115
115
| ✅ |[Extending](#extending)| Extend OpenFeature with custom providers and hooks. |
@@ -178,6 +178,89 @@ Logging customization is not yet available in the iOS SDK.
178
178
179
179
Support for named clients is not yet available in the iOS SDK.
180
180
181
+
### MultiProvider
182
+
183
+
The `MultiProvider` allows you to combine multiple feature flag providers into a single provider, enabling you to use different providers for different flags or implement fallback mechanisms. This is useful when migrating between providers, implementing A/B testing across providers, or ensuring high availability.
184
+
185
+
#### Basic Usage
186
+
187
+
```swift
188
+
importOpenFeature
189
+
190
+
Task {
191
+
// Create individual providers
192
+
let primaryProvider =PrimaryProvider()
193
+
let fallbackProvider =FallbackProvider()
194
+
195
+
// Create a MultiProvider with default FirstMatchStrategy
196
+
let multiProvider =MultiProvider(providers: [primaryProvider, fallbackProvider])
// Use flags normally - the MultiProvider will handle provider selection
202
+
let client = OpenFeatureAPI.shared.getClient()
203
+
let flagValue = client.getBooleanValue(key: "my-flag", defaultValue: false)
204
+
}
205
+
```
206
+
207
+
#### Evaluation Strategies
208
+
209
+
The `MultiProvider` supports different strategies for evaluating flags across multiple providers:
210
+
211
+
##### FirstMatchStrategy (Default)
212
+
213
+
The `FirstMatchStrategy` evaluates providers in order and returns the first result that doesn't indicate "flag not found". If a provider returns an error other than "flag not found", that error is returned immediately.
214
+
215
+
```swift
216
+
let multiProvider =MultiProvider(
217
+
providers: [primaryProvider, fallbackProvider],
218
+
strategy: FirstMatchStrategy()
219
+
)
220
+
```
221
+
222
+
##### FirstSuccessfulStrategy
223
+
224
+
The `FirstSuccessfulStrategy` evaluates providers in order and returns the first successful result (no error). Unlike `FirstMatchStrategy`, it continues to the next provider if any error occurs, including "flag not found".
225
+
226
+
```swift
227
+
let multiProvider =MultiProvider(
228
+
providers: [primaryProvider, fallbackProvider],
229
+
strategy: FirstSuccessfulStrategy()
230
+
)
231
+
```
232
+
233
+
#### Use Cases
234
+
235
+
**Provider Migration:**
236
+
```swift
237
+
// Gradually migrate from OldProvider to NewProvider
238
+
let multiProvider =MultiProvider(providers: [
239
+
NewProvider(), // Check new provider first
240
+
OldProvider() // Fall back to old provider
241
+
])
242
+
```
243
+
244
+
**High Availability:**
245
+
```swift
246
+
// Use multiple providers for redundancy
247
+
let multiProvider =MultiProvider(providers: [
248
+
RemoteProvider(),
249
+
LocalCacheProvider(),
250
+
StaticProvider()
251
+
])
252
+
```
253
+
254
+
**Environment-Specific Providers:**
255
+
```swift
256
+
// Different providers for different environments
257
+
let providers = [
258
+
EnvironmentProvider(environment: "production"),
259
+
DefaultProvider()
260
+
]
261
+
let multiProvider =MultiProvider(providers: providers)
262
+
```
263
+
181
264
### Eventing
182
265
183
266
Events allow you to react to state changes in the provider or underlying flag management system, such as flag definition changes, provider readiness, or error conditions.
0 commit comments