Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds allFlagMetadata to clients and provider interface #245

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions specification.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@
"RFC 2119 keyword": "MUST",
"children": []
},
{
"id": "Requirement 1.2.3",
"machine_id": "requirement_1_2_3",
"content": "The client interface MUST define a `all flag metadata` member or accessor, containing a `flags` field or accessor which is a collection of flag metadata, from the provider.",
"RFC 2119 keyword": "MUST",
"children": []
},
{
"id": "Condition 1.3.1",
"machine_id": "condition_1_3_1",
Expand Down Expand Up @@ -358,6 +365,13 @@
"RFC 2119 keyword": "MUST",
"children": []
},
{
"id": "Requirement 2.1.2",
"machine_id": "requirement_2_1_2",
"content": "The provider MAY define an `all flag metadata` field or accessor, containing a `flags` field or accessor which is a collection of flag metadata, identifying all available flag keys in the provider.",
"RFC 2119 keyword": "MAY",
"children": []
},
{
"id": "Requirement 2.2.1",
"machine_id": "requirement_2_2_1",
Expand Down
14 changes: 12 additions & 2 deletions specification/sections/01-flag-evaluation.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ This function not only sets the provider, but ensures that the provider is ready
// default provider
OpenFeatureAPI.getInstance().setProviderAndWait(myprovider); // this method blocks until the provider is ready or in error
// client uses the default provider
Client client = OpenFeatureAPI.getInstance().getClient();
Client client = OpenFeatureAPI.getInstance().getClient();

// provider associated with domain-1
OpenFeatureAPI.getInstance().setProviderAndWait('domain-1', myprovider); // this method blocks until the provider is ready or in error
Expand Down Expand Up @@ -171,6 +171,16 @@ client.getMetadata().getDomain(); // "domain-1"
In previous drafts, this property was called `name`.
For backwards compatibility, implementations should consider `name` an alias to `domain`.

#### Requirement 1.2.3

> The client interface **MUST** define a `all flag metadata` member or accessor, containing a `flags` field or accessor which is a collection of flag metadata, from the provider.

```typescript
client.getAllFlagMetadata() // { flags: [{"key": "featureA", "type": "boolean"}, {"key": "featureB", "type": "string"}] }
```

This may return a language-idiomatic way of describing the absence of a value if the provider does not implement the `allFlagMetadata` member or accessor.

### 1.3. Flag Evaluation

[![hardening](https://img.shields.io/static/v1?label=Status&message=hardening&color=yellow)](https://github.com/open-feature/spec/tree/main/specification#hardening)
Expand Down Expand Up @@ -506,4 +516,4 @@ see: [error codes](../types.md#error-code), [flag value resolution](./02-provide

The SDK ensures that if the provider's lifecycle methods terminate with an `error code`, that error code is included in any associated error events and returned/thrown errors/exceptions.

see: [error codes](../types.md#error-code)
see: [error codes](../types.md#error-code)
14 changes: 14 additions & 0 deletions specification/sections/02-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ Providers are the "translator" between the flag evaluation calls made in applica
provider.getMetadata().getName(); // "my-custom-provider"
```

#### Requirement 2.1.2

> The provider **MAY** define an `all flag metadata` field or accessor, containing a `flags` field or accessor which is a collection of flag metadata, identifying all available flag keys in the provider.

```typescript
provider.getAllFlagMetadata(); // { flags: [{"key": "featureA", "type": "boolean"}, {"key": "featureB", "type": "string"}] }
```

This operation should not be confused with a bulk evaluation of all flags.
This is an informative operation available to clients for understanding which flag keys are currently available from a provider.
Example usages include building a debug screen based on available flags and detecting stale flag evaluations.
For some providers, fetching all flags is an expensive operation. If there is language support, consider implementing this as an asynchronous operation.
If the provider does not implement this behavior or the flag metadata cannot currently be retrieved due to an error status, the language-idiomatic way of describing the absence of a value can be returned from this method.

### 2.2 Flag Value Resolution

`Providers` are implementations of the `feature provider` interface, which may wrap vendor SDKs, REST API clients, or otherwise resolve flag values from the runtime environment.
Expand Down
15 changes: 15 additions & 0 deletions specification/types.md
maxveldink marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ A numeric value of unspecified type or size. Implementation languages may furthe

Structured data, presented however is idiomatic in the implementation language, such as JSON or YAML.

### Collection

An unordered list or series of similar data types, presented however is idiomatic in the implementation language.

### Datetime

A language primitive for representing a date and time, optionally including timezone information. If no timezone is specified, the date and time will be treated as UTC.
Expand Down Expand Up @@ -122,9 +126,20 @@ A structure containing the following fields:
### Flag Metadata

A structure which supports definition of arbitrary properties, with keys of type `string`, and values of type `boolean`, `string`, or `number`.
`key` and `type` are reserved properties.

`key` is a required property with a value of type `string`.
`type` is an optional property with a value of type `string`, indicating which client resolution method should be used to resolve the flag key.
maxveldink marked this conversation as resolved.
Show resolved Hide resolved

This structure is populated by a provider for use by an [Application Author](./glossary.md#application-author) via the [Evaluation API](./glossary.md#evaluation-api) or an [Application Integrator](./glossary.md#application-integrator) via [hooks](./sections/04-hooks.md).

### Provider Metadata

A structure which carries information about the provider.
In addition to the defined metadata fields below, arbitrary information can be stored here unique to the provider.

`name` is a required key with a value of type string.

### Provider Status

An enumeration of possible provider states.
Expand Down
Loading