Skip to content

feat(cloudflare): slim OpenFeature provider for CF resolver#435

Draft
nicklasl wants to merge 3 commits into
mainfrom
nicklasl/openfeature-cloudflare-provider
Draft

feat(cloudflare): slim OpenFeature provider for CF resolver#435
nicklasl wants to merge 3 commits into
mainfrom
nicklasl/openfeature-cloudflare-provider

Conversation

@nicklasl

@nicklasl nicklasl commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

  • Plan for a new @spotify-confidence/openfeature-cloudflare-provider package
  • Slim OpenFeature provider (~150 LOC) that talks to the CF resolver via Cloudflare Service Binding
  • No WASM, no state polling, no log flushing, no client secret — the CF resolver handles all of that

What's in this PR

Just the plan (openfeature-provider/cloudflare/PLAN.md) for review. Implementation follows in subsequent commits.

Test plan

  • Review plan for completeness and correctness
  • Validate shared code extraction approach
  • Confirm waitUntil/ctx pattern matches confidence-sdk-js

🤖 Generated with Claude Code

nicklasl and others added 2 commits June 5, 2026 12:12
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nicklasl

nicklasl commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

Future direction: Unified provider with pluggable resolver

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:

interface Resolver {
  resolve(flags: string[], context: Record<string, any>): Promise<FlagBundle>;
  initialize?(): Promise<void>;
  close?(): Promise<void>;
}

Three resolver implementations, same provider:

Resolver Backend Use case
ServiceBindingResolver CF Worker via service binding Cloudflare Workers at the edge
LocalResolver In-process WASM + CDN state polling High-throughput servers (Node, Deno, Bun)
RemoteResolver HTTP to resolver.confidence.dev Simple setups, low-volume backends

What this PR already does toward that goal:

  • js-shared/flag-bundle.ts extracts the shared FlagBundle type and resolve()/evaluateAssignment() — this becomes the contract between provider and resolver
  • The CF provider's evaluate() method is essentially the unified provider pattern already (FlagBundle in, ResolutionDetails out)

What a follow-up would need to change:

  • 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).
  • Extract the provider shell — the ~50 LOC of OpenFeature glue (evaluate(), resolveBooleanEvaluation(), etc.) becomes the shared ConfidenceProvider class.
  • Unify FlagBundle creation — each resolver normalizes its response format (protobuf, JSON, etc.) to FlagBundle internally, so the provider never sees protocol-specific types.
  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant