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
refactor: use remote resolver fallback for sticky assignments
Remove MaterializationRepository from public API for now:
- Removed materializationRepository option from ProviderOptions
- Updated provider to always use remote resolver fallback for sticky assignments
- Materializations stored on Confidence servers with 90-day TTL
- Marked MaterializationRepository interface and utilities as WIP
Documentation updates:
- Updated README to explain remote fallback approach
- Added note about upcoming custom storage feature
- Marked MAT_REPO_EXAMPLES.md as work in progress
- Updated tests to reflect remote fallback behavior
The MaterializationRepository feature will be added in a future release
to allow users to connect their own storage (Redis, database, etc.).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Copy file name to clipboardExpand all lines: openfeature-provider/js/README.md
+19-48Lines changed: 19 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,7 +71,6 @@ await provider.onClose();
71
71
-`initializeTimeout` (number, optional): Max ms to wait for initial state fetch. Defaults to 30_000.
72
72
-`flushInterval` (number, optional): Interval in ms for sending evaluation logs. Defaults to 10_000.
73
73
-`fetch` (optional): Custom `fetch` implementation. Required for Node < 18; for Node 18+ you can omit.
74
-
-`materializationRepository` (optional): Custom storage for sticky assignments. See [Sticky Assignments](#sticky-assignments) below.
75
74
76
75
The provider periodically:
77
76
- Refreshes resolver state (default every 30s)
@@ -81,7 +80,7 @@ The provider periodically:
81
80
82
81
## Sticky Assignments
83
82
84
-
Confidence supports "sticky" flag assignments to ensure users receive consistent variant assignments even when their context changes or flag configurations are updated.
83
+
Confidence supports "sticky" flag assignments to ensure users receive consistent variant assignments even when their context changes or flag configurations are updated.
85
84
86
85
### How it works
87
86
@@ -90,66 +89,38 @@ When a flag is evaluated for a user, Confidence creates a "materialization" - a
90
89
- The flag's targeting rules are modified
91
90
- New assignments are paused
92
91
93
-
### Default behavior (no repository)
92
+
### Implementation
94
93
95
-
If you don't provide a `materializationRepository`, the provider automatically falls back to resolve with our cloud resolvers:
96
-
- Materializations are stored on Confidence servers with a 90-day TTL
94
+
The provider uses a **remote resolver fallback** for sticky assignments:
95
+
- First, the local WASM resolver attempts to resolve the flag
96
+
- If sticky assignment data is needed, the provider makes a network call to Confidence's cloud resolvers
97
+
- Materializations are stored on Confidence servers with a **90-day TTL** (automatically renewed on access)
// materializationRepository is optional - uses remote storage by default
106
105
});
107
-
```
108
106
109
-
### Custom storage with MaterializationRepository
107
+
// Sticky assignments work automatically via remote fallback
108
+
const client =OpenFeature.getClient();
109
+
const value =awaitclient.getBooleanValue('my-flag', false, {
110
+
targetingKey: 'user-123'
111
+
});
112
+
```
110
113
111
-
For advanced use cases where you want full control over materialization storage (e.g., Redis, database, file system), implement the `MaterializationRepository` interface:
114
+
### Benefits
112
115
113
-
```ts
114
-
interfaceMaterializationRepository {
115
-
/**
116
-
* Load ALL stored materialization assignments for a targeting unit.
117
-
*
118
-
* @paramunit - The targeting key (e.g., user ID, session ID)
119
-
* @parammaterialization - The materialization ID being requested (for context)
120
-
* @returns Map of materialization ID to MaterializationInfo for this unit
121
-
*/
122
-
loadMaterializedAssignmentsForUnit(
123
-
unit:string,
124
-
materialization:string
125
-
):Promise<Map<string, MaterializationInfo>>;
126
-
127
-
/**
128
-
* Store materialization assignments for a targeting unit.
129
-
*
130
-
* @paramunit - The targeting key (e.g., user ID, session ID)
131
-
* @paramassignments - Map of materialization ID to MaterializationInfo
132
-
*/
133
-
storeAssignment(
134
-
unit:string,
135
-
assignments:Map<string, MaterializationInfo>
136
-
):Promise<void>;
137
-
138
-
/**
139
-
* Close and cleanup any resources used by this repository.
140
-
*/
141
-
close():void|Promise<void>;
142
-
}
143
-
```
116
+
-**Zero configuration**: Works out of the box with no additional setup
117
+
-**Managed storage**: Confidence handles all storage, TTL, and consistency
118
+
-**Automatic renewal**: TTL is refreshed on each access
119
+
-**Global availability**: Materializations are available across all your services
144
120
145
-
**Key points:**
146
-
-`loadMaterializedAssignmentsForUnit` should return ALL materializations for the given unit, not just the one requested
147
-
- This allows efficient bulk loading from your storage system
148
-
- The provider handles caching and coordination internally
121
+
### Coming Soon: Custom Materialization Storage
149
122
150
-
See [MAT_REPO_EXAMPLES.md](./MAT_REPO_EXAMPLES.md) for complete implementation examples including:
151
-
- In-memory repository for testing
152
-
- File-backed repository for persistent storage
123
+
We're working on support for connecting your own materialization storage repository (Redis, database, file system, etc.) to eliminate network calls for sticky assignments and have full control over storage. This feature is currently in development.
0 commit comments