Commit 02e3c6d
authored
feat(bigtable): add SessionThrottler / AdaptiveSessionThrottler for OpenSession pacing (#20184)
## Summary
Adds `SessionThrottler` interface and `AdaptiveSessionThrottler`
implementation under `bigtable/internal/transport/`. This is a
concurrency governor with adaptive failure penalties for pacing
`OpenSession` calls, matching Java's `SessionCreationBudget`
(google-cloud-java: `SessionCreationBudget.java`).
- A failed `OpenSession` keeps its slot reserved for `penaltyDuration`
before returning it to the pool, so repeated failures throttle
further attempts.
- Counter+slice representation (rather than a chan-based semaphore)
lets `UpdateConfig` raise or lower the ceiling at runtime without
leaking in-flight callers.
- `Snapshot()` exposes `InUse` / `Capacity` / `PenaltyDuration` for
the debug UI.
This is a self-contained, unwired primitive (stdlib-only:
`context`, `sync`, `time`). A follow-up will wire it into
`SessionPoolImpl.UpdateConfig` and the session-creation path.
## Test plan
- [x] `go build ./internal/transport/...`
- [x] `go vet ./internal/transport/...`
- [x] `go test ./internal/transport/... -run 'Throttler' -count=1`
(7 tests: acquire/release success, block-at-cap, ctx respect,
failure-penalty slot hold, UpdateConfig grow unblocks,
UpdateConfig shrink honored, concurrent smoke)
- [x] `goimports -d` — no diffs
- [x] `golint ./internal/transport/session_creation_budget{,_test}.go` —
clean1 parent cf86793 commit 02e3c6d
0 file changed
0 commit comments