From 6b901c931ebefe2ca5932a4afb3d298dd6f9757f Mon Sep 17 00:00:00 2001 From: Aleksey Shakhmatov Date: Sat, 21 Mar 2026 13:06:30 +0300 Subject: [PATCH] Add CLAUDE.md and Gitea CI workflow Co-Authored-By: Claude Opus 4.6 (1M context) --- .gitea/workflows/ci.yml | 23 +++++++++++++++++++++++ CLAUDE.md | 30 ++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 .gitea/workflows/ci.yml create mode 100644 CLAUDE.md diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..a33b0dc --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,23 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: "1.24" + + - name: Vet + run: go vet ./... + + - name: Test + run: go test -race -count=1 ./... diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..3e96746 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,30 @@ +# CLAUDE.md — httpx + +## Commands + +```bash +go build ./... # compile +go test ./... # all tests +go test -race ./... # tests with race detector +go test -v -run TestName ./package/ # single test +go vet ./... # static analysis +``` + +## Architecture + +- **Module**: `git.codelab.vc/pkg/httpx`, Go 1.24, zero external dependencies +- **Core pattern**: middleware is `func(http.RoundTripper) http.RoundTripper` +- **Chain assembly order** (client.go): Logging → User MW → Retry → CB → Balancer → Transport + - Retry wraps CB+Balancer so each attempt can hit a different endpoint +- **Circuit breaker** is per-host (`sync.Map` of host → Breaker) +- **Sentinel errors**: canonical values live in sub-packages, root package re-exports as aliases +- **balancer.Transport** returns `(Middleware, *Closer)` — Closer must be tracked for health checker shutdown +- **Client.Close()** stops the health checker goroutine + +## Conventions + +- Functional options for all configuration +- Test helpers: `mockTransport(fn)` wrapping `middleware.RoundTripperFunc` +- No external test frameworks — stdlib only +- Thread safety required (`sync.Mutex`/`atomic`) +- `internal/clock` for deterministic time testing