2026-05-29 15:58:56 +00:00
|
|
|
// Package cachevalkey provides a lifecycle-aware Valkey client with health checks
|
|
|
|
|
// and three adapters that integrate with other Einherjar starters via duck typing.
|
|
|
|
|
//
|
|
|
|
|
// # Quick start
|
|
|
|
|
//
|
|
|
|
|
// vk := cachevalkey.New(logger, cfg)
|
2026-08-07 22:14:06 -06:00
|
|
|
// 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)
|
2026-05-29 15:58:56 +00:00
|
|
|
//
|
|
|
|
|
// # Adapters
|
|
|
|
|
//
|
|
|
|
|
// Each adapter wraps the Provider and satisfies one interface in another module.
|
|
|
|
|
// Go's structural typing handles the assignment — no cast required:
|
|
|
|
|
//
|
|
|
|
|
// permCache := cachevalkey.NewPermissionCache(vk) // → auth/rbac.Cache
|
|
|
|
|
// rateLimiter := cachevalkey.NewRateLimiterStore(vk, time.Second, 100) // → web/mw.RateLimiterStore
|
|
|
|
|
// blacklist := cachevalkey.NewBlacklist(vk) // → auth-jwt.Blacklist
|
|
|
|
|
//
|
|
|
|
|
// # Configuration
|
|
|
|
|
//
|
|
|
|
|
// Config fields carry caarlos0/env struct tags. Populate via environment variables
|
|
|
|
|
// or construct directly:
|
|
|
|
|
//
|
|
|
|
|
// cfg := cachevalkey.Config{
|
|
|
|
|
// Addrs: []string{"localhost:6379"},
|
|
|
|
|
// }
|
|
|
|
|
package cachevalkey
|