Stream beets imports over HTTP.

feat(server): cap pending import queue and concurrent dry-run previews #24

Merged glerp.sullen.net
targeting main from glerp.sullen.net/goosefoot:fix/import-admission-limits
Merged opened by and assigned to glerp.sullen.net
targeting main from glerp.sullen.net/goosefoot:fix/import-admission-limits

Summary #

  • Bound pending imports (DefaultMaxPendingImports = 16: 1 active + up to 15 queued) and concurrent dry-run previews (DefaultMaxConcurrentPreviews = 4) via independent chan struct{} semaphores on server.Server.
  • Reject excess requests immediately in handleImport with 429 Too Many Requests ("import queue is full" or "too many concurrent dry-run previews") after request validation and before opening an SSE stream (newSSEStream), holding each slot via defer until the handler completes.
  • Add behavioral unit tests verifying 429 admission rejection without SSE framing on saturated pending imports, independent dry_run: true execution while the import queue is saturated, and 429 rejection + slot recovery on MaxConcurrentPreviews.

Verification #

  • gofmt -l .
  • go vet ./...
  • go test -race -count=1 ./...
Commits 0