Microservice Configuration API
Centralized configuration management with type safety, caching, and real-time updates.
What It Does
The Microservice Configuration API provides a centralized, type-safe configuration management system for distributed microservices. It eliminates configuration duplication by storing key-value pairs centrally in Firestore with TTL caching and real-time update notifications.
Key Capabilities
- Centralized Storage: Single source of truth for all configuration
- Type Safety: Generic typing for configuration schemas
- TTL Caching: 5-minute cache with 10,000 entry max
- Real-Time Updates: RxJS observables for config changes
- Environment Override: Prefer environment variables over central config
- Batch Operations: Update multiple keys atomically
- Default Values: Fallback values for missing config
- Bypass Cache: Option for volatile/critical values
Main Components
ConfigurationService<T>
key<Key>(k: Key): Builder<T>
getAll(): Promise<Config>
setMany(config: Partial<Config>): Promise<void>Builder Pattern
Fluent API for individual keys:
const builder = configService.key('BACKGROUND_JOB_URL')
// Access patterns
await builder // Direct await
await builder.get() // Explicit get
await builder.get({default: 'http://localhost'}) // With default
await builder.get({envarOverride: true}) // Prefer env var
await builder.getOrError() // Throw if missing
builder.listen() // Observable for changes
await builder.set('new-value') // Update valueConfiguration Interface
IPlatformConfig
Predefined schema for Foundation services:
{
// Infrastructure
REDIS_HOST: string
REDIS_PORT: string
CLOUD_HOST: 'gcp' | 'cpln'
GVC_ALIAS: string
// Firebase/GCP
FIREBASE_API_KEY: string
GCP_PROJECT_NUMBER: string
// Service URLs
AUTH_REST_URL: string
BACKGROUND_JOB_REST_URL: string
MESSAGING_REST_URL: string
SSE_REST_URL: string
// Storage
CONTENT_BUCKET: string
PDF_BUCKET: string
CNAME: string
BROWSER_BASE_URL: string
// Defaults & Flags
DEFAULT_PRODUCT_IDS: string[]
INITIALIZE_SQL: boolean
FORCE_APP_ENGINE: boolean
}Storage Backend
FirestoreConfigurationEngine
- Document:
configuration/microservice-config - All config stored as key-value pairs in single document
- Real-time listeners via Firestore
getValueChanges - Batch upsert for efficient bulk updates
Caching Strategy
- TTL: 5 minutes
- Max Entries: 10,000
- Invalidation: Automatic on
setMany()operations - Bypass:
bypassCache: trueoption
Common Use Cases
- Multi-environment configuration (dev, staging, prod)
- Dynamic feature flags without redeployment
- Service discovery with centralized URLs
- Real-time configuration updates
- Type-safe config access across microservices
What Customers Don’t Have to Build
- Centralized configuration storage
- TTL-based caching infrastructure
- Real-time config change listeners
- Type-safe configuration access
- Environment variable override logic
- Batch configuration updates
- Firestore integration for config
- Configuration validation
Last updated on