docs(cache-valkey): fix fictional launcher.Register/health.Register in doc examples (#2)
The package-doc examples showed a fictional launcher.Register / health.Register API (and launcher.Append as a package func). Corrected to the real wiring: lc.Append + web/health.NewHandler(...).ServeHTTP. (component.go doc comment corrected too.) Documentation-only. No code, API, or dependency changes; version stays v1.1.0 (the v1.1.0 tag is moved to include this fix). Verified by compiling the corrected pattern against the real API. Reviewed-on: #2 Co-authored-by: Rene Nochebuena Guerrero <rene@nochebuena.dev> Co-committed-by: Rene Nochebuena Guerrero <rene@nochebuena.dev>
This commit was merged in pull request #2.
This commit is contained in:
@@ -17,8 +17,9 @@ import cachevalkey "code.nochebuena.dev/einherjar/cache-valkey"
|
|||||||
vk := cachevalkey.New(logger, cachevalkey.Config{
|
vk := cachevalkey.New(logger, cachevalkey.Config{
|
||||||
Addrs: []string{"localhost:6379"},
|
Addrs: []string{"localhost:6379"},
|
||||||
})
|
})
|
||||||
launcher.Register(vk) // OnInit → OnStart → OnStop
|
lc.Append(vk) // OnInit → OnStart → OnStop
|
||||||
health.Register(vk) // PING-based health check, LevelDegraded
|
// vk is observability.Checkable (PING-based, LevelDegraded):
|
||||||
|
srv.Get("/health", health.NewHandler(logger, vk).ServeHTTP)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Connecting to other modules
|
## Connecting to other modules
|
||||||
@@ -30,8 +31,8 @@ them directly to the consuming modules:
|
|||||||
```go
|
```go
|
||||||
// --- 1. Create the component (lifecycle + health + Provider) ---
|
// --- 1. Create the component (lifecycle + health + Provider) ---
|
||||||
vk := cachevalkey.New(logger, cfg)
|
vk := cachevalkey.New(logger, cfg)
|
||||||
launcher.Register(vk)
|
lc.Append(vk)
|
||||||
health.Register(vk)
|
srv.Get("/health", health.NewHandler(logger, vk).ServeHTTP)
|
||||||
|
|
||||||
// --- 2. Create adapters (one per consumer interface) ---
|
// --- 2. Create adapters (one per consumer interface) ---
|
||||||
// Each adapter wraps vk (a Provider) and satisfies one interface in another module.
|
// Each adapter wraps vk (a Provider) and satisfies one interface in another module.
|
||||||
|
|||||||
+4
-3
@@ -7,10 +7,11 @@ import (
|
|||||||
|
|
||||||
// Component is the full cache-valkey capability: lifecycle management, health checks,
|
// Component is the full cache-valkey capability: lifecycle management, health checks,
|
||||||
// and all Provider operations.
|
// 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)
|
// lc.Append(vk)
|
||||||
// health.Register(vk)
|
// srv.Get("/health", health.NewHandler(logger, vk).ServeHTTP)
|
||||||
type Component interface {
|
type Component interface {
|
||||||
lifecycle.Component
|
lifecycle.Component
|
||||||
observability.Checkable
|
observability.Checkable
|
||||||
|
|||||||
@@ -4,8 +4,9 @@
|
|||||||
// # Quick start
|
// # Quick start
|
||||||
//
|
//
|
||||||
// vk := cachevalkey.New(logger, cfg)
|
// vk := cachevalkey.New(logger, cfg)
|
||||||
// launcher.Register(vk) // lifecycle: OnInit → OnStart → OnStop
|
// lc.Append(vk) // lifecycle: OnInit → OnStart → OnStop
|
||||||
// health.Register(vk) // health: PING-based, LevelDegraded
|
// // vk satisfies observability.Checkable (PING-based, LevelDegraded) — wire a health endpoint:
|
||||||
|
// srv.Get("/health", health.NewHandler(logger, vk).ServeHTTP)
|
||||||
//
|
//
|
||||||
// # Adapters
|
// # Adapters
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user