docs(cache-valkey): fix fictional launcher.Register/health.Register in doc examples #2

Merged
Rene Nochebuena merged 1 commits from fix/wiring-docs into main 2026-08-07 22:18:54 -06:00
3 changed files with 12 additions and 9 deletions
+5 -4
View File
@@ -17,8 +17,9 @@ import cachevalkey "code.nochebuena.dev/einherjar/cache-valkey"
vk := cachevalkey.New(logger, cachevalkey.Config{
Addrs: []string{"localhost:6379"},
})
launcher.Register(vk) // OnInit → OnStart → OnStop
health.Register(vk) // PING-based health check, LevelDegraded
lc.Append(vk) // OnInit → OnStart → OnStop
// vk is observability.Checkable (PING-based, LevelDegraded):
srv.Get("/health", health.NewHandler(logger, vk).ServeHTTP)
```
## Connecting to other modules
@@ -30,8 +31,8 @@ them directly to the consuming modules:
```go
// --- 1. Create the component (lifecycle + health + Provider) ---
vk := cachevalkey.New(logger, cfg)
launcher.Register(vk)
health.Register(vk)
lc.Append(vk)
srv.Get("/health", health.NewHandler(logger, vk).ServeHTTP)
// --- 2. Create adapters (one per consumer interface) ---
// Each adapter wraps vk (a Provider) and satisfies one interface in another module.
+4 -3
View File
@@ -7,10 +7,11 @@ import (
// Component is the full cache-valkey capability: lifecycle management, health checks,
// and all Provider operations.
// Register with launcher and health before starting the application:
// Append it to a launcher, and wire a health endpoint (it satisfies
// observability.Checkable):
//
// launcher.Register(vk)
// health.Register(vk)
// lc.Append(vk)
// srv.Get("/health", health.NewHandler(logger, vk).ServeHTTP)
type Component interface {
lifecycle.Component
observability.Checkable
+3 -2
View File
@@ -4,8 +4,9 @@
// # Quick start
//
// vk := cachevalkey.New(logger, cfg)
// launcher.Register(vk) // lifecycle: OnInit → OnStart → OnStop
// health.Register(vk) // health: PING-based, LevelDegraded
// lc.Append(vk) // lifecycle: OnInit → OnStart → OnStop
// // vk satisfies observability.Checkable (PING-based, LevelDegraded) — wire a health endpoint:
// srv.Get("/health", health.NewHandler(logger, vk).ServeHTTP)
//
// # Adapters
//