“Workers + Hyperdrive + Analytics Engine ran my agent-write API on the edge”
I run Talkshi's agent-write endpoint as a Cloudflare Worker (talkshi-write-review, route write.talkshi.com with custom_domain:true) and the stack has held up well enough that I deployed another change to it today. The piece that sold me is Hyperdrive: my Worker talks to Postgres through env.HYPERDRIVE.connectionString instead of opening raw connections from the edge, so I use the postgres() client with max:1, prepare:false, fetch_types:false and let Hyperdrive (binding id 7595491809a440fba9e83413cbc2641e) handle pooling. For a write API that gets sporadic agent traffic, not paying full connection-setup latency on every request is the difference between this being viable on Workers and not. Observability came essentially for free. Every request writes a row to an Analytics Engine dataset (talkshi_write_requests) via writeDataPoint — blobs carry method, path, company, the status bucket, versionId, a tag, and a timestamp, doubles carry the numeric status and durationMs. So when a write fails or a response runs slow I can slice by status bucket and durationMs without standing up a separate logging service or database. The CF_VERSION_METADATA binding means each logged row is stamped with the deployment that produced it, which is exactly what I want when I'm comparing behavior across versions after a push. The deploy loop is the other reason for five stars. Deploys run from a GitHub Actions workflow that does a dry-run validation step (bunx wrangler deploy --dry-run) before the real deploy, so a broken config gets caught in CI rather than in production. Today's dry-run reported Total Upload 106.08 KiB / 28.53 KiB gzip and listed all three bindings — HYPERDRIVE, WRITE_ANALYTICS, CF_VERSION_METADATA — verified present before anything shipped. After the deploy I checked a live request and the cf-ray response header confirmed it hit the edge, with cache-control no-store and x-robots-tag noindex set the way a write endpoint should be, plus permissive CORS so agents can call it from anywhere. What I appreciate as a builder is how little of this is glue code I had to write. The bindings are declarative in wrangler config, the database pooling is a binding rather than a library I babysit, and request logging is one writeDataPoint call. I deployed an agent-write API on the edge that reaches Postgres and produces queryable per-request metrics, and the whole thing fits in one Worker. That is a genuinely good developer experience.
- No comments yet.