Skip to content

Support isolated billing workspaces - #57

Merged
midagedev merged 2 commits into
mainfrom
feature/multi-workspace-support
May 22, 2026
Merged

Support isolated billing workspaces#57
midagedev merged 2 commits into
mainfrom
feature/multi-workspace-support

Conversation

@midagedev

Copy link
Copy Markdown
Owner

요약

하나의 실행 중인 Billtap 서버가 완전히 격리된 여러 billing 데이터셋을 보유할 수 있도록 멀티 워크스페이스를 추가했습니다. 병렬 테스트 스위트가 더 이상 서버를 재시작하거나 공유 상태를 리셋하지 않고도 각자 독립된 데이터셋을 쓸 수 있습니다.

동작 방식

  • 하위호환: 워크스페이스 미지정 요청은 기존 database_url로 백킹되는 default 워크스페이스를 사용 — 기존 통합은 무수정 동작.
  • 선택: X-Billtap-Workspace 헤더 또는 ?workspace= 쿼리 파라미터. 해석된 이름은 X-Billtap-Workspace 응답 헤더로 에코.
  • 격리: 명명된 워크스페이스는 첫 요청 시 <dir>/workspaces/<name>.db에 자체 SQLite DB를 lazy하게 열고 독립 API 핸들러를 받음 → 고객·인보이스·웹훅·멱등성 키·test_clock까지 완전 격리.
  • 이름 규칙: 영문/숫자/./-/_, 선두는 영숫자, 대소문자 무시. 잘못된 이름은 400.
  • GET /workspaces — 알려진 워크스페이스 목록(메모리 + 디스크 스캔).

변경 파일

  • internal/server/workspace.go (신규) — workspaceManager: 워크스페이스 해석, lazy 스토어 오픈, 디스패치, 목록
  • internal/server/server.go/v1/·/api/를 워크스페이스 디스패처로 마운트, buildAPIHandler 추출, GET /workspaces, Close() 추가
  • cmd/billtap/main.go — 종료 시 lazy 워크스페이스 스토어 정리
  • internal/server/workspace_test.go (신규) — 격리·헤더·쿼리·목록·DSN 테스트
  • README.md / CHANGELOG.md — Workspaces 문서

검증

  • go build ./..., go vet ./..., go test ./... 전체 통과
  • 신규 테스트: 워크스페이스 간 데이터 격리, 쿼리 파라미터 해석, 헤더 에코/잘못된 이름 거부, /workspaces 목록, DSN 파생

알려진 제한

대시보드 및 호스티드 checkout/portal UI는 프론트엔드가 워크스페이스 헤더를 보내지 않는 한 default 워크스페이스를 봅니다. API를 직접 호출하는 테스트는 완전 격리됩니다. UI 워크스페이스 인지는 후속 작업입니다.

🤖 Generated with Claude Code

midagedev and others added 2 commits May 22, 2026 17:07
Allow one running server to hold several fully isolated billing datasets
so parallel test suites no longer have to restart the server or reset
shared state between runs.

Requests select a workspace with the X-Billtap-Workspace header or the
workspace query parameter; unselected requests keep using the
backward-compatible default workspace backed by the configured
database_url. Named workspaces open their own SQLite database lazily
under a workspaces/ directory and get an independent API handler, so
customers, invoices, webhooks, idempotency keys, and test clocks are all
isolated. GET /workspaces lists the known workspaces.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reflect the new isolated-workspace feature across the design docs and the
product spec: testing isolation guidance, the storage architecture note,
functional requirement FR-010, non-functional requirement NFR-008, the API
contract Workspaces section, the data-model scoping note, and tasks T147.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@midagedev
midagedev merged commit 5caa296 into main May 22, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant