Commit b6457f6
feat!: Spec v0.8 adherence (#46)
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->
## Spec v0.8 adherence
- Created "ProviderStatus.swift" according to
[Specification](https://github.com/open-feature/spec/blob/634f2b52f990232b0b1c54c38f422cbff2c507bc/specification/types.md#provider-status).
- ProviderState is now maintained by the SDK, and not by the Provider
implementations
- Align "ProviderEvent.swift" with
[Specification](https://github.com/open-feature/spec/blob/634f2b52f990232b0b1c54c38f422cbff2c507bc/specification/types.md#provider-events)
- Basic events like `Ready`, `Error` or `Fatal` are emitted by the SDK
and are not expected by the Provider implementations.
- Makes `initialize` and `onContextChange` protocols throwing, allowing
for the OpenFeatureAPI layer to detect cases where `Error` events should
be emitted
- Makes `initialize` and `onContextChange` protocols async for an easier
Provider implementation (in most cases)
### Missing parts
- From the
[Specification](https://openfeature.dev/specification/sections/events#conditional-requirement-5342):
`It's possible that the on context changed function is invoked
simultaneously or in quick succession; in this case the SDK will only
run the PROVIDER_CONTEXT_CHANGED handlers after all reentrant
invocations have terminated, and the last to terminate was successful
(terminated normally)`
- This is not part of this PR: subsequent calls are serialized and
executed in sequence, each returning from its execution even if more
same functions are queued
- Handling of [spontaneous Provider
events](https://openfeature.dev/specification/sections/events#requirement-535)
missing in this PR
## Changes unrelated to Spec v0.8
- Added `setEvaluationContextAndWait` to provide the same better
ergonomics that `setProviderAndWait` already offers
- Evaluation returns early if provider state is not "ready"
- Refactor `afterAll` hook to adhere to latest conventions
## Notes on backwards compatibility
- A backwards incompatible aspect of this change is that the
`initialize()` implementation needs to throw in case of errors, rather
than emitting the `ERROR` event. The latter is now responsibility of the
SDK. This is also valid for `onContextChange`.
- This change in semantics is not enforced with code, and it might be
easy for the Provider implementer to make mistakes when adopting this
new version of the SDK (e.g. forget to remove `ERROR` emission from the
Provider side)
## Example Adoption
The Confidence OpenFeature Provider adopting this version of the SDK is
in the works here:
spotify/confidence-sdk-swift#184
---------
Signed-off-by: Fabrizio Demaria <[email protected]>
Co-authored-by: Michael Beemer <[email protected]>1 parent b900743 commit b6457f6
File tree
24 files changed
+505
-307
lines changed- Sources/OpenFeature
- Provider
- exceptions
- Tests/OpenFeatureTests
- Helpers
24 files changed
+505
-307
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | | - | |
| 93 | + | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| |||
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
156 | 161 | | |
157 | 162 | | |
158 | 163 | | |
| |||
242 | 247 | | |
243 | 248 | | |
244 | 249 | | |
245 | | - | |
| 250 | + | |
246 | 251 | | |
247 | 252 | | |
248 | 253 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
9 | 8 | | |
10 | 9 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 10 | + | |
| 11 | + | |
17 | 12 | | |
18 | 13 | | |
19 | 14 | | |
20 | 15 | | |
21 | 16 | | |
22 | | - | |
| 17 | + | |
23 | 18 | | |
24 | 19 | | |
25 | 20 | | |
26 | 21 | | |
27 | | - | |
| 22 | + | |
28 | 23 | | |
29 | 24 | | |
30 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| |||
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
34 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
35 | 41 | | |
36 | 42 | | |
37 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
| 7 | + | |
| 8 | + | |
18 | 9 | | |
| 10 | + | |
19 | 11 | | |
20 | | - | |
| 12 | + | |
21 | 13 | | |
22 | 14 | | |
23 | 15 | | |
| |||
32 | 24 | | |
33 | 25 | | |
34 | 26 | | |
35 | | - | |
36 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
37 | 30 | | |
38 | | - | |
39 | 31 | | |
40 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
16 | 13 | | |
17 | | - | |
18 | 14 | | |
19 | 15 | | |
20 | 16 | | |
21 | 17 | | |
22 | 18 | | |
23 | 19 | | |
24 | 20 | | |
25 | | - | |
26 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
33 | 45 | | |
34 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
35 | 62 | | |
36 | 63 | | |
37 | 64 | | |
38 | | - | |
| 65 | + | |
39 | 66 | | |
40 | 67 | | |
41 | 68 | | |
42 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
43 | 73 | | |
44 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
45 | 79 | | |
46 | | - | |
47 | | - | |
48 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
49 | 100 | | |
50 | 101 | | |
51 | 102 | | |
52 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
53 | 108 | | |
54 | 109 | | |
55 | 110 | | |
| |||
72 | 127 | | |
73 | 128 | | |
74 | 129 | | |
75 | | - | |
| 130 | + | |
76 | 131 | | |
77 | 132 | | |
78 | 133 | | |
| 134 | + | |
| 135 | + | |
79 | 136 | | |
80 | | - | |
| 137 | + | |
81 | 138 | | |
82 | 139 | | |
83 | 140 | | |
84 | 141 | | |
85 | 142 | | |
86 | 143 | | |
87 | | - | |
88 | 144 | | |
89 | | - | |
90 | | - | |
91 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
92 | 152 | | |
93 | 153 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
106 | 174 | | |
107 | 175 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
112 | 190 | | |
113 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
114 | 198 | | |
0 commit comments