Feat/booking service#6
Merged
Merged
Conversation
- Add handler for tenant service with routes for health check, create, list, get, update, and delete tenants. - Implement PostgreSQL repository for tenant management, including methods for creating, retrieving, listing, updating, and soft-deleting tenants. - Create unit tests for handler methods to ensure proper functionality and error handling. - Define repository interface for abstraction and ease of testing.
Adds github.com/jackc/pgx/v5 v5.6.0 as a direct dependency of
tenant-service (the implementation was already committed) and updates
go.sum + go.work.sum with the verified checksums.
• go.mod: pgx/v5 v5.6.0 direct; pgpassfile, pgservicefile, crypto as
indirect; golang.org/x/text pinned to 0.14.0; go directive kept at
1.23.0 to stay consistent with the workspace and CI toolchain
• go.sum / go.work.sum: generated by go mod tidy after merging the
go-common/logger package (feat/go-common-logger) into dev so the
workspace can resolve all imports
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… cache
- domain/apikey.go: APIKey aggregate, CreateParams, Environment, KeyStatus,
sentinel errors (ErrNotFound, ErrInvalidKey, ErrExpiredKey)
- keygen/keygen.go: crypto/rand key generation (sf_live_/sf_test_ prefix +
64 hex chars), SHA-256 hashing; raw key never persisted
- repository/repository.go: Repository interface (Create, GetByID, List,
Revoke, GetByHash, UpdateLastUsed, Ping)
- repository/postgres.go: pgx/v5 implementation; array scan for module_scope;
pgtype.Timestamptz for nullable timestamps
- cache/cache.go: Cache interface + RedisCache (JSON-serialised APIKey with
5-minute TTL) + NoopCache for tests
- handler/handler.go: POST /v1/keys, GET /v1/keys, GET /v1/keys/{id},
DELETE /v1/keys/{id}, POST /v1/keys/validate, GET /health; validate uses
Redis fast-path with Postgres fallback; last_used_at updated asynchronously
- handler/handler_test.go: 15 tests with in-memory fakeRepo + NoopCache
- packages/go-common/tenant: export DefaultTenant sentinel and NewContext
helper so handlers and tests can detect/inject tenant IDs without HTTP
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- go.mod: add jackc/pgx/v5 v5.6.0 and redis/go-redis/v9 v9.5.1 as direct deps - go.sum / go.work.sum: updated checksums Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…and rate limiter - registry/registry.go: static service registry loaded from env vars (AUTH_SERVICE_URL, TENANT_SERVICE_URL, BOOKING_SERVICE_URL, CONFIG_SERVICE_URL) - proxy/proxy.go: httputil.ReverseProxy wrapper; strips Authorization header before forwarding, structured JSON 502 on upstream failure - middleware/auth.go: Bearer-token validation via auth-service POST /v1/keys/validate; injects X-Tenant-ID and X-Key-Environment on success - middleware/ratelimit.go: per-tenant fixed-window rate limiter (sync.Map, configurable limit/window via RATE_LIMIT env, Phase 1 in-memory) - cmd/server/main.go: wires all components; authenticated routes: /v1/bookings/* → booking-service, /v1/config/* → config-service; admin routes (no auth): /v1/tenants/*, /v1/keys/*; graceful shutdown Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new context-aware, structured logger for all ServiceForge services, built on Go's standard
log/slogpackage. It provides consistent logging with tenant and trace ID enrichment, HTTP middleware for request logging, and comprehensive tests. Additionally, it improves the tenant context package and makes minor dependency and configuration updates.The most important changes are:
Logging Infrastructure
loggerpackage (packages/go-common/logger/logger.go) providing a structured, context-aware logger with support for log levels, formats, service tagging, and automatic enrichment with tenant and trace IDs. Includes HTTP middleware for request logging and helpers for context propagation.packages/go-common/logger/logger_test.go), covering log level filtering, context enrichment, HTTP middleware, and trace/tenant ID handling.Tenant Context Improvements
DefaultTenantas a constant intenant/context.gofor easier detection of unauthenticated requests, and addedNewContextfor direct context construction in tests and internal code. [1] [2]Dependency and Configuration Updates
go.workto 1.25.0 and reordered module paths.go.work.sumfor Redis, hashing, and rendezvous support..claude/settings.jsonto allow specificgo getandgo versioncommands.Documentation and Formatting
docs/on-prem/docker-compose.ymlfor better readability. [1] [2] [3] [4] [5] [6]