Skip to content

Commit c97d701

Browse files
nicklaslclaude
andauthored
docs: update cloudflare resolver deployer README (#301)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent ecc7eaa commit c97d701

File tree

1 file changed

+55
-21
lines changed
  • confidence-cloudflare-resolver/deployer

1 file changed

+55
-21
lines changed
Lines changed: 55 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
# CloudFlare Resolver Worker Deployer
1+
# Confidence Cloudflare Resolver Deployer
22

3-
Docker container used to deploy the Confidence Rust resolver to CloudFlare.
3+
Docker-based deployer that handles building and publishing the Confidence resolver Worker to your Cloudflare account. The resolver enables feature flag evaluation at Cloudflare's edge locations worldwide, powered by the [Confidence Resolver](https://github.com/spotify/confidence-resolver).
4+
5+
## Features
6+
7+
* **Edge evaluation**: Flag rules evaluate at Cloudflare's edge locations worldwide
8+
* **Ultra-low latency**: Evaluation happens close to users, minimizing latency
9+
* **Rust-based resolver**: High-performance flag evaluation powered by the Confidence Resolver
10+
* **Deployer-driven sync**: Run the deployer to fetch the latest flag rules from Confidence and re-deploy the Worker
411

512
## Build
613

@@ -10,35 +17,62 @@ From the **root of the repository**, run:
1017
docker build --target confidence-cloudflare-resolver.deployer -t <YOUR_IMAGE_NAME> .
1118
```
1219

20+
A pre-built image is also available at `ghcr.io/spotify/confidence-cloudflare-deployer:latest`.
21+
22+
## Prerequisites
23+
24+
* Docker installed
25+
* Cloudflare API token with the following permissions:
26+
* **Account > Workers Scripts > Edit**
27+
* **Account > Workers Queues > Edit** (needed for the first deploy)
28+
* Confidence client secret (must be type **BACKEND**)
29+
1330
## Usage
1431

15-
A CloudFlare queue named `flag-logs-queue` must be enabled on your CloudFlare project. If this is your first setup, make sure to run this first:
16-
```
17-
wrangler queues create flag-logs-queue
32+
On the first deploy, create the required Cloudflare Queue:
33+
34+
```bash
35+
CLOUDFLARE_API_TOKEN='your-cloudflare-api-token' npx wrangler queues create flag-logs-queue
1836
```
1937

20-
Docker run to deploy the resolver and your latest flags state:
38+
Then run the deployer with your credentials:
39+
2140
```bash
2241
docker run -it \
23-
-e CLOUDFLARE_API_TOKEN='<your-cloudflare-api-token>' \
24-
-e CONFIDENCE_CLIENT_SECRET='<your-confidence-client-secret>' \
25-
<YOUR_IMAGE_NAME>
42+
-e CLOUDFLARE_API_TOKEN='your-cloudflare-api-token' \
43+
-e CONFIDENCE_CLIENT_SECRET='your-confidence-client-secret' \
44+
ghcr.io/spotify/confidence-cloudflare-deployer:latest
2645
```
2746

28-
You can get the `CONFIDENCE_CLIENT_SECRET` from the Confidence dashboard, under `Clients`.
47+
The deployer automatically detects:
48+
49+
* **Cloudflare account ID** from your API token
50+
* **Resolver state** from Confidence CDN
51+
* **Existing deployment** to avoid unnecessary re-deploys
52+
53+
> **Note:** The deployer does not poll for changes. Each run fetches the current state from Confidence, deploys the Worker if the state has changed, and then exits. To keep the Worker up to date, run the deployer on a schedule (for example, via a cron job) or trigger it when flag rules or targeting changes are made in Confidence.
2954
3055
## Optional Variables
3156

32-
| Variable | Description |
33-
|----------|-------------|
34-
| `CLOUDFLARE_ACCOUNT_ID` | Required only if the API token has access to multiple accounts |
35-
| `CONFIDENCE_RESOLVER_STATE_URL` | Custom resolver state URL (overrides default URL to Confidence CDN) |
36-
| `CONFIDENCE_RESOLVER_ALLOWED_ORIGIN` | Configure allowed origins for CORS |
37-
| `RESOLVE_TOKEN_ENCRYPTION_KEY` | AES-128 key (base64 encoded) used to encrypt resolve tokens when `apply=false`. Not needed since the resolver defaults `apply` to `true` |
38-
| `FORCE_DEPLOY` | Force re-deploy regardless of state changes |
39-
| `NO_DEPLOY` | Build only, skip deployment |
57+
| Variable | Description |
58+
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
59+
| `CLOUDFLARE_ACCOUNT_ID` | Required only if the API token has access to multiple accounts |
60+
| `CONFIDENCE_RESOLVER_STATE_URL` | Custom resolver state URL (overrides default URL to Confidence CDN) |
61+
| `CONFIDENCE_RESOLVER_ALLOWED_ORIGIN` | Configure allowed origins for CORS |
62+
| `RESOLVE_TOKEN_ENCRYPTION_KEY` | AES-128 key (base64 encoded) used to encrypt resolve tokens when `apply=false`. Not needed since the resolver defaults `apply` to `true` |
63+
| `FORCE_DEPLOY` | Force re-deploy regardless of state changes |
64+
| `NO_DEPLOY` | Build only, skip deployment |
65+
66+
## Service Binding vs HTTP Calls
67+
68+
When integrating with the Cloudflare resolver, you have two options:
69+
70+
**Service binding (recommended)**: Cloudflare's [service bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/) allow Workers to call other Workers directly within Cloudflare's network. This internal routing bypasses the public internet, resulting in ultra-low latency.
71+
72+
**HTTP calls**: Standard HTTP requests to the resolver endpoint. Use this approach when calling from external services or client applications.
73+
74+
For more details on integration, including code examples using the [`@spotify-confidence/sdk`](https://github.com/spotify/confidence-sdk-js), see the [Confidence documentation](https://confidence.spotify.com/docs/sdks/edge/cloudflare#cloudflare-workers).
4075

41-
## Sticky Assignments
76+
## Limitations
4277

43-
Sticky assignments are not currently supported with the CloudFlare resolver.
44-
Flags with sticky assignment rules will return "flag not found".
78+
* **Sticky assignments**: Not currently supported with the Cloudflare resolver. Flags with sticky assignment rules will return "flag not found".

0 commit comments

Comments
 (0)