Firebase App component with launcher lifecycle and health check integration.
What's included:
- Config with ProjectID (FIREBASE_PROJECT_ID env var); credentials via ADC
- Provider interface exposing native *firebase.App directly
- Component interface: launcher.Component + health.Checkable + Provider
- New(logger, cfg) constructor for lifecycle registration via lc.Append
- Health check via GetUser("health-probe-non-existent") + auth.IsUserNotFound at LevelCritical
- No-op OnStop (Firebase Admin SDK has no Close method)
Tested-via: todo-api POC integration
Reviewed-against: docs/adr/
2.1 KiB
2.1 KiB
Changelog
All notable changes to this module will be documented in this file.
The format is based on Keep a Changelog, and this module adheres to Semantic Versioning.
0.9.0 - 2026-03-18
Added
Configstruct — Firebase connection settings loaded from environment variables:FIREBASE_PROJECT_ID(required, Google Cloud project ID); credentials are resolved via Application Default Credentials (ADC)Providerinterface —App() *firebase.App; for consumers that only need the Firebase Admin SDK entry pointComponentinterface — embedslauncher.Component,health.Checkable, andProvider; the full lifecycle-managed surface registered with the launcherNew(logger logz.Logger, cfg Config) Component— constructor; returns aComponentready forlc.AppendOnInit— validatesProjectID, then callsfb.NewAppto construct the Admin SDK*firebase.AppOnStart— no-op beyond logging; connectivity is verified byHealthCheckOnStop— no-op log statement; the Firebase Admin SDK exposes noClosemethodHealthCheck(ctx context.Context) error— callsGetUser("health-probe-non-existent")on the Auth client; treatsauth.IsUserNotFoundas healthy (confirms the service is reachable); any other error is a health failureName() string— returns"firebase"Priority() health.Level— returnshealth.LevelCritical; a Firebase Auth outage is treated as a critical failure
Design Notes
- The native
*firebase.Appis exposed directly viaApp(); callers obtain service-specific clients themselves (e.g.app.Auth(ctx),app.Firestore(ctx)), keeping this module free of service proliferation. - The health check uses a sentinel UID (
"health-probe-non-existent") rather than string-matching error messages, making it robust against Firebase error message changes. Provider/Componentsplit follows the framework pattern: injectProviderinto services that only needApp(), injectComponentonly at the lifecycle registration site.