Skip to content

Commit 40c613e

Browse files
nicklaslclaude
andcommitted
docs(cloudflare): add future unified provider direction to plan
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c96d170 commit 40c613e

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

  • openfeature-provider/cloudflare

openfeature-provider/cloudflare/PLAN.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,36 @@ No WASM dependency, no proto generation — this stage is fast and self-containe
197197

198198
No `@bufbuild/protobuf`, no `debug`, no React/Next.js. The package is tiny.
199199

200+
## Future: Unified provider with pluggable resolver
201+
202+
The shared code extraction in PR 1 and the CF provider in PR 2 are stepping stones toward a single `ConfidenceProvider` with a pluggable `Resolver` interface:
203+
204+
```ts
205+
interface Resolver {
206+
resolve(flags: string[], context: Record<string, any>): Promise<FlagBundle>;
207+
initialize?(): Promise<void>;
208+
close?(): Promise<void>;
209+
}
210+
```
211+
212+
Three resolver implementations, same provider:
213+
214+
| Resolver | Backend | Use case |
215+
|----------|---------|----------|
216+
| `ServiceBindingResolver` | CF Worker via service binding | Cloudflare Workers at the edge |
217+
| `LocalResolver` | In-process WASM + CDN state polling | High-throughput servers (Node, Deno, Bun) |
218+
| `RemoteResolver` | HTTP to `resolver.confidence.dev` | Simple setups, low-volume backends |
219+
220+
**What this PR already does toward that goal:**
221+
- `js-shared/flag-bundle.ts` extracts the shared `FlagBundle` type and `resolve()`/`evaluateAssignment()` — this becomes the contract between provider and resolver
222+
- The CF provider's `evaluate()` method is essentially the unified provider pattern already (FlagBundle in, ResolutionDetails out)
223+
224+
**What a follow-up would need to change:**
225+
- **Refactor `ConfidenceServerProviderLocal`** — move state polling, log flushing, materialization orchestration, and WASM lifecycle out of the provider class and into a `LocalResolver` implementation. This is the bulk of the work (~400 LOC moves from provider to resolver).
226+
- **Extract the provider shell** — the ~50 LOC of OpenFeature glue (`evaluate()`, `resolveBooleanEvaluation()`, etc.) becomes the shared `ConfidenceProvider` class.
227+
- **Unify `FlagBundle` creation** — each resolver normalizes its response format (protobuf, JSON, etc.) to `FlagBundle` internally, so the provider never sees protocol-specific types.
228+
- **Package consolidation** — either merge into one package with entry points (`/local`, `/cloudflare`, `/remote`) or keep a core + resolver packages. A single package with entry points is simpler but means renaming from `@spotify-confidence/openfeature-server-provider-local` (breaking change). Separate resolver packages avoid the rename but add maintenance surface.
229+
200230
## Reused code
201231

202232
| Code | Location | Used by |

0 commit comments

Comments
 (0)