diff --git a/Sources/ConfidenceProvider/README.md b/Sources/ConfidenceProvider/README.md index fb6cc4af..83f74f82 100644 --- a/Sources/ConfidenceProvider/README.md +++ b/Sources/ConfidenceProvider/README.md @@ -1,5 +1,5 @@ # OpenFeature Provider -If you want to use OpenFeature, an OpenFeature Provider for the [OpenFeature SDK](https://github.com/open-feature/kotlin-swift) is also available. +If you want to use OpenFeature, an OpenFeature Provider for the [OpenFeature SDK](https://github.com/open-feature/kotlin-sdk) is also available. ## Usage @@ -27,7 +27,7 @@ import Confidence import ConfidenceProvider import OpenFeature -let confidence = Confidence.Builder(clientSecret: "mysecret").build() +let confidence = Confidence.Builder(clientSecret: "mysecret", loggerLevel: .NONE).build() let provider = ConfidenceFeatureProvider(confidence: confidence) let ctx = MutableContext(targetingKey: "myTargetingKey", structure: MutableStructure()) OpenFeatureAPI.shared.setProvider(provider: provider, initialContext: ctx) @@ -42,7 +42,7 @@ There is also an `async/await` compatible API available for waiting the Provider await OpenFeatureAPI.shared.setProviderAndWait(provider: provider) ``` -A utility function is available on the provider to check if the current storage has any values stored - this can be used to determine the best initialization strategy. +A utility function is available on the provider to check if the current storage has any stored values - this can be used to determine the best initialization strategy. ```swift // If we have no cache, then do a fetch first. var initializationStrategy: InitializationStrategy = .activateAndFetchAsync @@ -64,7 +64,7 @@ OpenFeatureAPI.shared.observe().sink { event in } ``` -**Note:** if you do attempt to resolve a flag before the READY event is emitted, you may receive the default value with reason `STALE`. +**Note:** if you do attempt to resolve a flag before the READY event is emitted, you may receive the default value with the reason `STALE`. There are other events that are emitted by the provider, see [Provider Events](https://openfeature.dev/specification/types#provider-events) in the Open Feature specification for more details. @@ -78,11 +78,13 @@ OpenFeatureAPI.shared.setEvaluationContext(evaluationContext: ctx) `setEvaluationContext()` is a synchronous function similar to `setProvider()`. It calls the Confidence backend to fetch the flag evaluations according to the new evaluation context; if the call is successful, it replaces the cache with the new flag data. -**Note:** the initialization strategy is not taken into consideration when calling `setEvaluationContext()`, so it's required to wait for READY before resuming to resolve flags. +**Notes:** -**Note:** if you do attempt to resolve a flag before the READY event is emitted, you may receive the old value with reason `STALE`. +- The initialization strategy is not taken into consideration when calling `setEvaluationContext()`, so it's required to wait for READY before resuming to resolve flags. -**Note:** a "targeting key" in the evaluation context is expected by the OpenFeature APIs, but a different custom field inside the `structure` value can also be configured as randomization unit in the Confidence portal. In this case, it's ok to leave `targetingKey` empty. +- If you do attempt to resolve a flag before the READY event is emitted, you may receive the old value with the reason `STALE`. + +- A "targeting key" in the evaluation context is expected by the OpenFeature APIs, but a different custom field inside the `structure` value can also be configured as the randomization unit in the Confidence portal. In this case, it's okay to leave `targetingKey` empty. ### Handling Provider Errors @@ -107,10 +109,9 @@ let client = OpenFeatureAPI.shared.getClient() let result = client.getBooleanValue(key: "my-flag.my-boolean", defaultValue: false) ``` -Confidence allows each flag value to be a complex data structure including multiple properties of different type. To access a specific flag's property, the dot notation in the example above is used. The full data structure for a flag can be always fetched via: +In Confidence each flag value is a complex data structure including one or more properties of different types. To access a specific flag's property, the dot notation in the example above is used. The full data structure for a flag can always be fetched via: ```swift let result = client.getObjectValue(key: "my-flag", defaultValue: Value.null) ``` **Note:** if a flag can't be resolved from the local cache, the provider doesn't automatically resort to calling remote. Refreshing the cache from remote only happens when setting a new provider and/or evaluation context in the global OpenFeatureAPI. -