From b4c608dd6cd81f1adbd6fecda9c3824656b2ad5b Mon Sep 17 00:00:00 2001 From: Thomas Poignant Date: Sat, 12 Aug 2023 09:20:00 +0200 Subject: [PATCH 1/9] feat: blocking setProvider Signed-off-by: Thomas Poignant --- specification/sections/01-flag-evaluation.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/specification/sections/01-flag-evaluation.md b/specification/sections/01-flag-evaluation.md index 8889636e..6929ae4c 100644 --- a/specification/sections/01-flag-evaluation.md +++ b/specification/sections/01-flag-evaluation.md @@ -105,6 +105,17 @@ The name is a logical identifier for the client. Clients may be created in critical code paths, and even per-request in server-side HTTP contexts. Therefore, in keeping with the principle that OpenFeature should never cause abnormal execution of the first party application, this function should never throw. Abnormal execution in initialization should instead occur during provider registration. +#### Requirement 1.1.8 + +> The `API` **SHOULD** provide functions to set a provider and wait for the `initialize` function to return or throw. + +The `API` will ensure that the provider is ready or in error before being able to initializing the client. + +```typescript +await Openfeature.setProviderAndWait(myprovider) +const client = Openfeature.getClient() +``` + ### 1.2. Client Usage #### Requirement 1.2.1 From 672785ba89e7e050f4cc0659b4e57b2bbde9f4d5 Mon Sep 17 00:00:00 2001 From: Thomas Poignant Date: Sat, 12 Aug 2023 09:23:50 +0200 Subject: [PATCH 2/9] fix example Signed-off-by: Thomas Poignant --- specification/sections/01-flag-evaluation.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/specification/sections/01-flag-evaluation.md b/specification/sections/01-flag-evaluation.md index 6929ae4c..08f6ec4f 100644 --- a/specification/sections/01-flag-evaluation.md +++ b/specification/sections/01-flag-evaluation.md @@ -112,8 +112,13 @@ Clients may be created in critical code paths, and even per-request in server-si The `API` will ensure that the provider is ready or in error before being able to initializing the client. ```typescript -await Openfeature.setProviderAndWait(myprovider) -const client = Openfeature.getClient() +// default client +await Openfeature.setProviderAndWait(myprovider); +const client = Openfeature.getClient(); + +// named client +await Openfeature.setProviderAndWait('client-name', myprovider); +const client = Openfeature.getClient('client-name'); ``` ### 1.2. Client Usage From bba4072ae005485280bf0fd1c2a3637b02af7b58 Mon Sep 17 00:00:00 2001 From: Thomas Poignant Date: Sat, 12 Aug 2023 09:25:24 +0200 Subject: [PATCH 3/9] missing parse Signed-off-by: Thomas Poignant --- specification.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/specification.json b/specification.json index d051c13d..384c9bf6 100644 --- a/specification.json +++ b/specification.json @@ -63,6 +63,13 @@ "RFC 2119 keyword": "MUST NOT", "children": [] }, + { + "id": "Requirement 1.1.8", + "machine_id": "requirement_1_1_8", + "content": "The `API` SHOULD provide functions to set a provider and wait for the `initialize` function to return or throw.", + "RFC 2119 keyword": "SHOULD", + "children": [] + }, { "id": "Requirement 1.2.1", "machine_id": "requirement_1_2_1", From 520e3d47401604398ab6981453448e10ffebf6ba Mon Sep 17 00:00:00 2001 From: Thomas Poignant Date: Sat, 12 Aug 2023 09:46:10 +0200 Subject: [PATCH 4/9] missing word Signed-off-by: Thomas Poignant --- specification/sections/01-flag-evaluation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/sections/01-flag-evaluation.md b/specification/sections/01-flag-evaluation.md index 08f6ec4f..93c4b1fe 100644 --- a/specification/sections/01-flag-evaluation.md +++ b/specification/sections/01-flag-evaluation.md @@ -109,7 +109,7 @@ Clients may be created in critical code paths, and even per-request in server-si > The `API` **SHOULD** provide functions to set a provider and wait for the `initialize` function to return or throw. -The `API` will ensure that the provider is ready or in error before being able to initializing the client. +The `API` will ensure that the provider initialization is ready or in error before being able to initializing the client. ```typescript // default client From 81f4982512417cc087e9a2873ca83d7568ece020 Mon Sep 17 00:00:00 2001 From: Thomas Poignant Date: Sat, 12 Aug 2023 09:46:39 +0200 Subject: [PATCH 5/9] Revert "missing word" This reverts commit a26f27b3d18a7fb1f7d3017074d289bed3250392. Signed-off-by: Thomas Poignant --- specification/sections/01-flag-evaluation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/sections/01-flag-evaluation.md b/specification/sections/01-flag-evaluation.md index 93c4b1fe..08f6ec4f 100644 --- a/specification/sections/01-flag-evaluation.md +++ b/specification/sections/01-flag-evaluation.md @@ -109,7 +109,7 @@ Clients may be created in critical code paths, and even per-request in server-si > The `API` **SHOULD** provide functions to set a provider and wait for the `initialize` function to return or throw. -The `API` will ensure that the provider initialization is ready or in error before being able to initializing the client. +The `API` will ensure that the provider is ready or in error before being able to initializing the client. ```typescript // default client From deb37f9ae1c7efafe6385c3be0cd9cc4960565c9 Mon Sep 17 00:00:00 2001 From: Thomas Poignant Date: Mon, 14 Aug 2023 21:22:42 +0200 Subject: [PATCH 6/9] Update specification/sections/01-flag-evaluation.md Co-authored-by: Todd Baert Signed-off-by: Thomas Poignant Signed-off-by: Thomas Poignant --- specification/sections/01-flag-evaluation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/sections/01-flag-evaluation.md b/specification/sections/01-flag-evaluation.md index 08f6ec4f..b6a08ad6 100644 --- a/specification/sections/01-flag-evaluation.md +++ b/specification/sections/01-flag-evaluation.md @@ -109,7 +109,7 @@ Clients may be created in critical code paths, and even per-request in server-si > The `API` **SHOULD** provide functions to set a provider and wait for the `initialize` function to return or throw. -The `API` will ensure that the provider is ready or in error before being able to initializing the client. +This function not only sets the provider, but ensures that the provider is ready (or in error) before returning or settling. ```typescript // default client From c4a77785860643861a99beadccdb23aa5c1a1727 Mon Sep 17 00:00:00 2001 From: Thomas Poignant Date: Mon, 14 Aug 2023 21:23:12 +0200 Subject: [PATCH 7/9] Update specification/sections/01-flag-evaluation.md Co-authored-by: Todd Baert Signed-off-by: Thomas Poignant Signed-off-by: Thomas Poignant --- specification/sections/01-flag-evaluation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/specification/sections/01-flag-evaluation.md b/specification/sections/01-flag-evaluation.md index b6a08ad6..ec7db1d5 100644 --- a/specification/sections/01-flag-evaluation.md +++ b/specification/sections/01-flag-evaluation.md @@ -121,6 +121,8 @@ await Openfeature.setProviderAndWait('client-name', myprovider); const client = Openfeature.getClient('client-name'); ``` +Though it's possible to use [events](./05-events.md) to await provider readiness, such functions can make things simpler for `application authors` and `integrators`. + ### 1.2. Client Usage #### Requirement 1.2.1 From 30b5a1f6b367ef111736bcc0c462a1c51496a734 Mon Sep 17 00:00:00 2001 From: Thomas Poignant Date: Mon, 14 Aug 2023 21:27:30 +0200 Subject: [PATCH 8/9] Use java for examples Signed-off-by: Thomas Poignant --- specification/sections/01-flag-evaluation.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/specification/sections/01-flag-evaluation.md b/specification/sections/01-flag-evaluation.md index ec7db1d5..8c9b5a85 100644 --- a/specification/sections/01-flag-evaluation.md +++ b/specification/sections/01-flag-evaluation.md @@ -111,14 +111,14 @@ Clients may be created in critical code paths, and even per-request in server-si This function not only sets the provider, but ensures that the provider is ready (or in error) before returning or settling. -```typescript +```java // default client -await Openfeature.setProviderAndWait(myprovider); -const client = Openfeature.getClient(); +OpenFeatureAPI.getInstance().setProviderAndWait(myprovider); +Client client = OpenFeatureAPI.getInstance().getClient(); // named client -await Openfeature.setProviderAndWait('client-name', myprovider); -const client = Openfeature.getClient('client-name'); +OpenFeatureAPI.getInstance().setProviderAndWait('client-name', myprovider); +Client client = OpenFeatureAPI.getInstance().getClient('client-name'); ``` Though it's possible to use [events](./05-events.md) to await provider readiness, such functions can make things simpler for `application authors` and `integrators`. From ee80ce2c0dd4d2e2172638f5f3ff225989a85362 Mon Sep 17 00:00:00 2001 From: Thomas Poignant Date: Mon, 14 Aug 2023 21:28:22 +0200 Subject: [PATCH 9/9] add comments Signed-off-by: Thomas Poignant --- specification/sections/01-flag-evaluation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/specification/sections/01-flag-evaluation.md b/specification/sections/01-flag-evaluation.md index 8c9b5a85..d8fe7987 100644 --- a/specification/sections/01-flag-evaluation.md +++ b/specification/sections/01-flag-evaluation.md @@ -113,11 +113,11 @@ This function not only sets the provider, but ensures that the provider is ready ```java // default client -OpenFeatureAPI.getInstance().setProviderAndWait(myprovider); -Client client = OpenFeatureAPI.getInstance().getClient(); +OpenFeatureAPI.getInstance().setProviderAndWait(myprovider); // this method blocks until the provider is ready or in error +Client client = OpenFeatureAPI.getInstance().getClient(); // named client -OpenFeatureAPI.getInstance().setProviderAndWait('client-name', myprovider); +OpenFeatureAPI.getInstance().setProviderAndWait('client-name', myprovider); // this method blocks until the provider is ready or in error Client client = OpenFeatureAPI.getInstance().getClient('client-name'); ```