Skip to content

Commit 776ee1f

Browse files
authored
feat!: add evaluation details to finally hook (#280)
Signed-off-by: Michael Beemer <[email protected]>
1 parent d4a9a91 commit 776ee1f

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

specification.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@
692692
{
693693
"id": "Requirement 4.1.2",
694694
"machine_id": "requirement_4_1_2",
695-
"content": "The `hook context` SHOULD provide: access to the `client metadata` and the `provider metadata` fields.",
695+
"content": "The `hook context` SHOULD provide access to the `client metadata` and the `provider metadata` fields.",
696696
"RFC 2119 keyword": "SHOULD",
697697
"children": []
698698
},
@@ -721,7 +721,7 @@
721721
{
722722
"id": "Requirement 4.2.1",
723723
"machine_id": "requirement_4_2_1",
724-
"content": "`hook hints` MUST be a structure supports definition of arbitrary properties, with keys of type `string`, and values of type `boolean | string | number | datetime | structure`..",
724+
"content": "`hook hints` MUST be a structure supports definition of arbitrary properties, with keys of type `string`, and values of type `boolean | string | number | datetime | structure`.",
725725
"RFC 2119 keyword": "MUST",
726726
"children": []
727727
},
@@ -808,7 +808,7 @@
808808
{
809809
"id": "Requirement 4.3.6",
810810
"machine_id": "requirement_4_3_6",
811-
"content": "The `after` stage MUST run after flag resolution occurs. It accepts a `hook context` (required), `flag evaluation details` (required) and `hook hints` (optional). It has no return value.",
811+
"content": "The `after` stage MUST run after flag resolution occurs. It accepts a `hook context` (required), `evaluation details` (required) and `hook hints` (optional). It has no return value.",
812812
"RFC 2119 keyword": "MUST",
813813
"children": []
814814
},
@@ -822,7 +822,7 @@
822822
{
823823
"id": "Requirement 4.3.8",
824824
"machine_id": "requirement_4_3_8",
825-
"content": "The `finally` hook MUST run after the `before`, `after`, and `error` stages. It accepts a `hook context` (required) and `hook hints` (optional). There is no return value.",
825+
"content": "The `finally` hook MUST run after the `before`, `after`, and `error` stages. It accepts a `hook context` (required), `evaluation details` (required) and `hook hints` (optional). It has no return value.",
826826
"RFC 2119 keyword": "MUST",
827827
"children": []
828828
},

specification/sections/04-hooks.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Hooks add their logic at any of four specific stages of flag evaluation:
1414

1515
- `before`, immediately before flag evaluation
1616
- `after`, immediately after successful flag evaluation
17-
- `error`, immediately after an unsuccessful during flag evaluation
18-
- `finally` unconditionally after flag evaluation
17+
- `error`, immediately after an unsuccessful flag evaluation
18+
- `finally`, unconditionally after flag evaluation
1919

2020
```mermaid
2121
flowchart LR
@@ -27,11 +27,14 @@ flowchart LR
2727
E -..-> F
2828
```
2929

30-
Hooks can be configured to run globally (impacting all flag evaluations), per client, or per flag evaluation invocation. Some example use-cases for hook include adding additional data to the [evaluation context](./03-evaluation-context.md), performing validation on the received flag value, providing data to telemetric tools, and logging errors.
30+
Hooks can be configured to run globally (impacting all flag evaluations), per client, or per flag evaluation invocation. Some example use cases for a hook include adding additional data to the [evaluation context](./03-evaluation-context.md), performing validation on the received flag value, providing data to telemetric tools, and logging errors.
3131

3232
### Definitions
3333

34-
**Hook**: Application author/integrator-supplied logic that is called by the OpenFeature framework at a specific stage. **Stage**: An explicit portion of the flag evaluation lifecycle. e.g. `before` being "before the [resolution](../glossary.md#resolving-flag-values) is run. **Invocation**: A single call to evaluate a flag. `client.getBooleanValue(..)` is an invocation. **API**: The global API singleton.
34+
**Hook**: Application author/integrator-supplied logic that is called by the OpenFeature framework at a specific stage.
35+
**Stage**: An explicit portion of the flag evaluation lifecycle. e.g. `before` being "before" the [resolution](../glossary.md#resolving-flag-values) is run.
36+
**Invocation**: A single call to evaluate a flag. `client.getBooleanValue(..)` is an invocation.
37+
**API**: The global API singleton.
3538

3639
### 4.1. Hook context
3740

@@ -43,7 +46,7 @@ Hook context exists to provide hooks with information about the invocation.
4346
4447
#### Requirement 4.1.2
4548

46-
> The `hook context` **SHOULD** provide: access to the `client metadata` and the `provider metadata` fields.
49+
> The `hook context` **SHOULD** provide access to the `client metadata` and the `provider metadata` fields.
4750
4851
#### Requirement 4.1.3
4952

@@ -63,7 +66,7 @@ see: [dynamic-context paradigm](../glossary.md#dynamic-context-paradigm)
6366

6467
#### Requirement 4.2.1
6568

66-
> `hook hints` **MUST** be a structure supports definition of arbitrary properties, with keys of type `string`, and values of type `boolean | string | number | datetime | structure`..
69+
> `hook hints` **MUST** be a structure supports definition of arbitrary properties, with keys of type `string`, and values of type `boolean | string | number | datetime | structure`.
6770
6871
#### Condition 4.2.2
6972

@@ -129,15 +132,17 @@ Evaluation context merge order is defined in [Context levels and merging](./03-e
129132

130133
#### Requirement 4.3.6
131134

132-
> The `after` stage **MUST** run after flag resolution occurs. It accepts a `hook context` (required), `flag evaluation details` (required) and `hook hints` (optional). It has no return value.
135+
> The `after` stage **MUST** run after flag resolution occurs. It accepts a `hook context` (required), `evaluation details` (required) and `hook hints` (optional). It has no return value.
133136
134137
#### Requirement 4.3.7
135138

136139
> The `error` hook **MUST** run when errors are encountered in the `before` stage, the `after` stage or during flag resolution. It accepts `hook context` (required), `exception` representing what went wrong (required), and `hook hints` (optional). It has no return value.
137140
138141
#### Requirement 4.3.8
139142

140-
> The `finally` hook **MUST** run after the `before`, `after`, and `error` stages. It accepts a `hook context` (required) and `hook hints` (optional). There is no return value.
143+
> The `finally` hook **MUST** run after the `before`, `after`, and `error` stages. It accepts a `hook context` (required), `evaluation details` (required) and `hook hints` (optional). It has no return value.
144+
145+
The evaluation details passed to the `finally` stage matches the evaluation details returned to the application author.
141146

142147
#### Condition 4.3.9
143148

@@ -179,7 +184,7 @@ client.getValue('my-flag', 'defaultValue', new Hook3());
179184

180185
> If a `finally` hook abnormally terminates, evaluation **MUST** proceed, including the execution of any remaining `finally` hooks.
181186

182-
In languages with try/catch semantics, this means that exceptions thrown in `finally` hooks should be caught, and not propagated up the call stack.
187+
In languages with try/catch semantics, this means that exceptions thrown in `finally` hooks should be caught and not propagated up the call stack.
183188

184189
#### Requirement 4.4.4
185190

0 commit comments

Comments
 (0)