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
@@ -76,6 +81,14 @@ The maintainer of a shared library which is a dependency of many applications or
76
81
77
82
The libraries used by the Application Author to implement feature flags in their application or service. The interfaces defined in these libraries adhere to the Feature Flag API.
78
83
84
+
### Client-Side SDK
85
+
86
+
An SDK which is built for usage in client applications (e.g. single-page web applications), and typically uses the [static-context paradigm](#static-context-paradigm).
87
+
88
+
### Server-Side SDK
89
+
90
+
An SDK which is built for usage in server applications (e.g. REST services), and typically uses the [dynamic-context paradigm](#dynamic-context-paradigm).
91
+
79
92
### Feature Flag API
80
93
81
94
The interfaces and abstractions used by authors (Application, Integration, Provider).
@@ -163,3 +176,25 @@ Pseudorandomly resolve flag values using a context property, such as a targeting
163
176
### Rule
164
177
165
178
A rule is some criteria that's used to determine which variant a particular context should be mapped to.
179
+
180
+
## SDK Paradigms
181
+
182
+
Feature flag frameworks have SDKs which operate in two distinct paradigms: those designed for use with a single user client application (e.g. mobile phones, single-page web apps), and those designed for multi-user applications, such as web server applications. Some parts of the OpenFeature specification diverge depending on the paradigm.
183
+
184
+
### Dynamic-Context Paradigm
185
+
186
+
Server-side applications typically perform flag evaluations on behalf of many users, with each request or event being associated with a particular user or client. For this reason, server frameworks typically operate similarly to this:
187
+
188
+
- the application is initialized with some static context (geography, service name, hostname, etc)
189
+
- with each request or event, relevant dynamic context (for example, user session data, unique user identifiers) is provided to flag evaluations
190
+
191
+
### Static-Context Paradigm
192
+
193
+
In contrast to server-side or other service-type applications, client side applications typically operate in the context of a single user. Most feature flagging libraries for these applications have been designed with this in mind. Frequently, client/web libraries operate similarly to this:
194
+
195
+
- an initialization occurs, which fetches evaluated flags in bulk for a given context (user)
196
+
- the evaluated flags are cached in the library
197
+
- flag evaluations take place against this cache, without a need to provide context (context was already used to evaluate flags in bulk)
198
+
- libraries provide a mechanism to update context (e.g. if a user logs in), meaning cached evaluations are no longer valid and must be re-evaluated, frequently involving a network request or I/O operation
199
+
200
+
Not all client libraries work this way, but generally, libraries that accept dynamic context per evaluation can build providers which conform to this model with relative ease, while the reverse is not true.
> The `client`**MUST** provide methods for typed flag evaluation, including boolean, numeric, string, and structure, with parameters `flag key` (string, required), `default value` (boolean | number | string | structure, required), `evaluation context` (optional), and `evaluation options` (optional), which returns the flag value.
136
142
@@ -152,10 +158,37 @@ See [evaluation context](./03-evaluation-context.md) for details.
152
158
153
159
#### Condition 1.3.2
154
160
155
-
> The implementation language differentiates between floating-point numbers and integers.
> The `client`**MUST** provide methods for typed flag evaluation, including boolean, numeric, string, and structure, with parameters `flag key` (string, required), `default value` (boolean | number | string | structure, required), and `evaluation options` (optional), which returns the flag value.
> The implementation language differentiates between floating-point numbers and integers.
189
+
190
+
##### Conditional Requirement 1.3.3.1
191
+
159
192
> The client **SHOULD** provide functions for floating-point numbers and integers, consistent with language idioms.
160
193
161
194
```java
@@ -166,15 +199,21 @@ long getFloatValue(String flag, long defaultValue);
166
199
167
200
See [types](../types.md) for details.
168
201
169
-
#### Requirement 1.3.3
202
+
#### Requirement 1.3.4
170
203
171
204
> The `client`**SHOULD** guarantee the returned value of any typed flag evaluation method is of the expected type. If the value returned by the underlying provider implementation does not match the expected type, it's to be considered abnormal execution, and the supplied `default value` should be returned.
> The `client`**MUST** provide methods for detailed flag value evaluation with parameters `flag key` (string, required), `default value` (boolean | number | string | structure, required), `evaluation context` (optional), and `evaluation options` (optional), which returns an `evaluation details` structure.
> The `client`**MUST** provide methods for detailed flag value evaluation with parameters `flag key` (string, required), `default value` (boolean | number | string | structure, required), and `evaluation options` (optional), which returns an `evaluation details` structure.
> The `evaluation details` structure's `value` field **MUST** contain the evaluated flag value.
199
265
200
-
#### Condition 1.4.3
266
+
#### Condition 1.4.4
201
267
202
268
> The language supports generics (or an equivalent feature).
203
269
204
-
##### Conditional Requirement 1.4.3.1
270
+
##### Conditional Requirement 1.4.4.1
205
271
206
272
> The `evaluation details` structure **SHOULD** accept a generic argument (or use an equivalent language feature) which indicates the type of the wrapped `value` field.
207
273
208
-
#### Requirement 1.4.4
274
+
#### Requirement 1.4.5
209
275
210
276
> The `evaluation details` structure's `flag key` field **MUST** contain the `flag key` argument passed to the detailed flag evaluation method.
211
277
212
-
#### Requirement 1.4.5
278
+
#### Requirement 1.4.6
213
279
214
280
> In cases of normal execution, the `evaluation details` structure's `variant` field **MUST** contain the value of the `variant` field in the `flag resolution` structure returned by the configured `provider`, if the field is set.
215
281
216
-
#### Requirement 1.4.6
282
+
#### Requirement 1.4.7
217
283
218
284
> In cases of normal execution, the `evaluation details` structure's `reason` field **MUST** contain the value of the `reason` field in the `flag resolution` structure returned by the configured `provider`, if the field is set.
219
285
220
-
#### Requirement 1.4.7
286
+
#### Requirement 1.4.8
221
287
222
288
> In cases of abnormal execution, the `evaluation details` structure's `error code` field **MUST** contain an `error code`.
223
289
224
290
See [error code](../types.md#error-code) for details.
225
291
226
-
#### Requirement 1.4.8
292
+
#### Requirement 1.4.9
227
293
228
294
> In cases of abnormal execution (network failure, unhandled error, etc) the `reason` field in the `evaluation details`**SHOULD** indicate an error.
229
295
230
-
#### Requirement 1.4.9
296
+
#### Requirement 1.4.10
231
297
232
298
> Methods, functions, or operations on the client **MUST NOT** throw exceptions, or otherwise abnormally terminate. Flag evaluation calls must always return the `default value` in the event of abnormal execution. Exceptions include functions or methods for the purposes for configuration or setup.
233
299
234
300
Configuration code includes code to set the provider, instantiate providers, and configure the global API object.
235
301
236
-
#### Requirement 1.4.10
302
+
#### Requirement 1.4.11
237
303
238
304
> In the case of abnormal execution, the client **SHOULD** log an informative error message.
239
305
240
306
Implementations may define a standard logging interface that can be supplied as an optional argument to the client creation function, which may wrap standard logging functionality of the implementation language.
241
307
242
-
#### Requirement 1.4.11
308
+
#### Requirement 1.4.12
243
309
244
310
> The `client`**SHOULD** provide asynchronous or non-blocking mechanisms for flag evaluation.
245
311
246
312
It's recommended to provide non-blocking mechanisms for flag evaluation, particularly in languages or environments wherein there's a single thread of execution.
247
313
248
-
#### Requirement 1.4.12
314
+
#### Requirement 1.4.13
249
315
250
316
> In cases of abnormal execution, the `evaluation details` structure's `error message` field **MAY** contain a string containing additional details about the nature of the error.
251
317
252
-
#### Requirement 1.4.13
318
+
#### Requirement 1.4.14
253
319
254
320
> If the `flag metadata` field in the `flag resolution` structure returned by the configured `provider` is set, the `evaluation details` structure's `flag metadata` field **MUST** contain that value. Otherwise, it **MUST** contain an empty record.
255
321
256
322
This `flag metadata` field is intended as a mechanism for providers to surface additional information about a feature flag (or its evaluation) beyond what is defined within the OpenFeature spec itself. The primary consumer of this information is a provider-specific hook.
257
323
258
-
#### Condition 1.4.14
324
+
#### Condition 1.4.15
259
325
260
326
> The implementation language supports a mechanism for marking data as immutable.
Copy file name to clipboardExpand all lines: specification/sections/02-providers.md
+25-1Lines changed: 25 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,7 +77,7 @@ The value of the variant field might only be meaningful in the context of the fl
77
77
78
78
#### Requirement 2.2.5
79
79
80
-
> The `provider`**SHOULD** populate the `resolution details` structure's `reason` field with `"STATIC"`, `"DEFAULT",``"TARGETING_MATCH"`, `"SPLIT"`, `"CACHED"`, `"DISABLED"`, `"UNKNOWN"`, `"ERROR"` or some other string indicating the semantic reason for the returned flag value.
80
+
> The `provider`**SHOULD** populate the `resolution details` structure's `reason` field with `"STATIC"`, `"DEFAULT",``"TARGETING_MATCH"`, `"SPLIT"`, `"CACHED"`, `"DISABLED"`, `"UNKNOWN"`, `"STALE"`, `"ERROR"` or some other string indicating the semantic reason for the returned flag value.
81
81
82
82
As indicated in the definition of the [`resolution details`](../types.md#resolution-details) structure, the `reason` should be a string. This allows providers to reflect accurately why a flag was resolved to a particular value.
83
83
@@ -245,6 +245,30 @@ class MyProvider implements Provider, AutoDisposable {
245
245
voiddispose() {
246
246
// close connections, terminate threads or timers, etc...
Static-context focused providers may need a mechanism to understand when their cache of evaluated flags must be invalidated or updated. An `on context changed` handler can be defined which performs whatever operations are needed to reconcile the evaluated flags with the new context.
255
+
256
+
#### Requirement 2.6.1
257
+
258
+
> The provider **MAY** define an `on context changed` handler, which takes an argument for the previous context and the newly set context, in order to respond to an evaluation context change.
259
+
260
+
Especially in static-context implementations, providers and underlying SDKs may maintain state for a particular context.
261
+
The `on context changed` handler provides a mechanism to update this state, often by re-evaluating flags in bulk with respect to the new context.
262
+
263
+
```java
264
+
// MyProvider implementation of the onContextChanged function defined in Provider
> The API, Client and invocation **MUST** have a method for supplying `evaluation context`.
50
56
51
57
API (global) `evaluation context` can be used to supply static data to flag evaluation, such as an application identifier, compute region, or hostname. Client and invocation `evaluation context` are ideal for dynamic data, such as end-user attributes.
> The API **MUST** have a method for setting the global `evaluation context`.
70
+
71
+
API (global) `evaluation context` can be used to supply data to flag evaluation, such as (but not limited to) user name, email, or user organization membership changes.
72
+
73
+
##### Conditional Requirement 3.2.2.2
74
+
75
+
> The Client and invocation **MUST NOT** have a method for supplying `evaluation context`.
76
+
77
+
In the static-context paradigm, context is global. The client and invocation cannot supply evaluation context.
78
+
79
+
#### Requirement 3.2.3
54
80
55
81
> Evaluation context **MUST** be merged in the order: API (global; lowest precedence) -> client -> invocation -> before hooks (highest precedence), with duplicate values being overwritten.
0 commit comments