|
| 1 | +# Confidence Mock Support Server (Go) |
| 2 | + |
| 3 | +Single-binary mock of Confidence HTTP and gRPC backends for provider benchmarks and tests. |
| 4 | + |
| 5 | +## Features |
| 6 | +- HTTP endpoints: |
| 7 | + - POST /v1/oauth/token → { accessToken, expiresIn } |
| 8 | + - GET /v1/resolverState:resolverStateUri → { signedUri, account } |
| 9 | + - GET /state.pb → serves resolver state bytes with ETag + 304 |
| 10 | + - POST /v1/flags:resolve → ResolveFlagsResponse (JSON) |
| 11 | + - POST /v1/flagLogs:write → 200 OK (accepts application/x-protobuf) |
| 12 | + - GET /healthz → 200 OK |
| 13 | +- gRPC endpoints: |
| 14 | + - confidence.flags.admin.v1.ResolverStateService (ResolverStateUri, FullResolverState) |
| 15 | + - confidence.flags.resolver.v1.InternalFlagLoggerService (WriteFlagLogs, WriteFlagAssigned) |
| 16 | +- One process, one container. No sidecars needed. |
| 17 | + |
| 18 | +Note: Public gRPC stubs for FlagResolverService are not generated here, so flags resolve is provided over HTTP only. |
| 19 | + |
| 20 | +## Configuration (env) |
| 21 | +- PORT_HTTP (default 8081) |
| 22 | +- PORT_GRPC (default 9091) |
| 23 | +- ACCOUNT_ID (default read from data/account_id) |
| 24 | +- RESOLVER_STATE_PB (default data/resolver_state_current.pb if present) |
| 25 | +- STATIC_TOKEN (default "mock-token") |
| 26 | +- TOKEN_EXPIRES_IN (default 3600) |
| 27 | +- FLAGS_RESPONSE_MODE (static|echo|file) [currently static] |
| 28 | +- STATIC_FLAG_VARIANT (default flags/foo/variants/default) |
| 29 | +- STATIC_FLAG_VALUE (default {"value":true}) |
| 30 | + |
| 31 | +## Build and run |
| 32 | + |
| 33 | +Docker build: |
| 34 | +```bash |
| 35 | +docker build -f mock-support-server/Dockerfile -t cnfd-mock . |
| 36 | +``` |
| 37 | + |
| 38 | +Run: |
| 39 | +```bash |
| 40 | +docker run --rm -p 8081:8081 -p 9091:9091 \ |
| 41 | + -e ACCOUNT_ID=test-account \ |
| 42 | + -e RESOLVER_STATE_PB=/data/resolver_state_current.pb \ |
| 43 | + cnfd-mock |
| 44 | +``` |
| 45 | + |
| 46 | +## Using with JS benchmark |
| 47 | +- Override provider fetch to route Confidence hosts to http://mock:8081 |
| 48 | +- Or run the benchmark container in a compose network and target `mock:8081` |
| 49 | + |
| 50 | +## Notes |
| 51 | +- Extend as needed to support additional endpoints or behaviors. |
| 52 | +- grpc-gateway can be added later if you want REST<->gRPC parity on one port. |
| 53 | + |
| 54 | + |
0 commit comments