Skip to content

Feat/booking service#6

Merged
PramithaMJ merged 10 commits into
mainfrom
feat/booking-service
Apr 16, 2026
Merged

Feat/booking service#6
PramithaMJ merged 10 commits into
mainfrom
feat/booking-service

Conversation

@PramithaMJ
Copy link
Copy Markdown
Member

This pull request introduces a new context-aware, structured logger for all ServiceForge services, built on Go's standard log/slog package. 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

  • Added a new logger package (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.
  • Added comprehensive tests for the logger package (packages/go-common/logger/logger_test.go), covering log level filtering, context enrichment, HTTP middleware, and trace/tenant ID handling.

Tenant Context Improvements

  • Exported DefaultTenant as a constant in tenant/context.go for easier detection of unauthenticated requests, and added NewContext for direct context construction in tests and internal code. [1] [2]

Dependency and Configuration Updates

  • Updated Go version in go.work to 1.25.0 and reordered module paths.
  • Added new dependencies to go.work.sum for Redis, hashing, and rendezvous support.
  • Added .claude/settings.json to allow specific go get and go version commands.

Documentation and Formatting

  • Improved section headers in docs/on-prem/docker-compose.yml for better readability. [1] [2] [3] [4] [5] [6]

PramithaMJ and others added 10 commits April 16, 2026 10:25
- 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>
@PramithaMJ PramithaMJ self-assigned this Apr 16, 2026
@PramithaMJ PramithaMJ added the enhancement New feature or request label Apr 16, 2026
@PramithaMJ PramithaMJ merged commit cfdb1a0 into main Apr 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant