feat(valkey): initial stable release v0.9.0

Valkey (Redis-compatible) client component with launcher lifecycle and health check integration.

What's included:
- Config with Addrs, Password, SelectDB, CacheSizeEachConn (env-driven)
- Provider interface exposing native valkey-go Client() directly (no wrapper)
- Component interface: launcher.Component + health.Checkable + Provider
- New(logger, cfg) constructor for lifecycle registration via lc.Append
- Health check via PING at LevelDegraded priority
- Graceful shutdown calling client.Close() in OnStop

Tested-via: todo-api POC integration
Reviewed-against: docs/adr/
This commit is contained in:
2026-03-19 13:29:28 +00:00
commit eda54153d6
13 changed files with 490 additions and 0 deletions

46
valkey_test.go Normal file
View File

@@ -0,0 +1,46 @@
package valkey
import (
"testing"
"code.nochebuena.dev/go/health"
"code.nochebuena.dev/go/logz"
)
func newLogger() logz.Logger { return logz.New(logz.Options{}) }
func TestNew(t *testing.T) {
if New(newLogger(), Config{}) == nil {
t.Fatal("New returned nil")
}
}
func TestComponent_Name(t *testing.T) {
c := New(newLogger(), Config{}).(health.Checkable)
if c.Name() != "valkey" {
t.Errorf("want valkey, got %s", c.Name())
}
}
func TestComponent_Priority(t *testing.T) {
c := New(newLogger(), Config{}).(health.Checkable)
if c.Priority() != health.LevelDegraded {
t.Error("Priority() != LevelDegraded")
}
}
func TestComponent_OnStop_NilClient(t *testing.T) {
c := &vkComponent{logger: newLogger()}
if err := c.OnStop(); err != nil {
t.Errorf("OnStop with nil client: %v", err)
}
}
func TestComponent_OnInit_InvalidAddr(t *testing.T) {
// An empty Addrs slice should cause NewClient to fail or produce an error.
c := New(newLogger(), Config{Addrs: []string{}})
err := c.OnInit()
// valkey-go may not error on empty addr until first command;
// just verify it doesn't panic and returns a component.
_ = err
}