replace Redis with an embedded SQLite string->string KV store (group commit, in-tx events, SQL search)
Build and Push Docker Image / build (push) Successful in 2m44s

This commit is contained in:
Worph
2026-10-19 20:51:00 +00:00
parent c53146e514
commit dc5cbdfb9b
80 changed files with 4601 additions and 6077 deletions
+9 -24
View File
@@ -30,36 +30,21 @@ func main() {
// Create leader info provider (Go binary only runs as leader - followers loop in bash)
leaderProvider := leader.NewLeaderInfoProvider(cfg)
// Connect to local Redis (supervisord starts Redis before meta-core)
// Retry connection since Redis may still be loading its dataset
redisURL := fmt.Sprintf("redis://localhost:%d", cfg.RedisPort)
log.Printf("[meta-core] Connecting to Redis at %s", redisURL)
storageClient := storage.NewClient("")
maxRetries := 30
retryDelay := 1 // seconds
var err error
for i := 0; i < maxRetries; i++ {
err = storageClient.Connect(redisURL)
if err == nil {
break
}
log.Printf("[meta-core] Redis connection attempt %d/%d failed: %v", i+1, maxRetries, err)
time.Sleep(time.Duration(retryDelay) * time.Second)
// Open the metadata store: an embedded SQLite file (internal/kv). There
// is no separate database process to wait for.
storageClient := storage.NewClient()
if err := storageClient.Connect(cfg.DBPath()); err != nil {
log.Fatalf("[meta-core] Failed to open the metadata store: %v", err)
}
if err != nil {
log.Fatalf("[meta-core] Failed to connect to Redis after %d attempts: %v", maxRetries, err)
}
log.Println("[meta-core] Connected to Redis")
// Schema-version sentinel: alpha clean-wipe gate. Refuses to boot when
// the existing Redis store predates the UUID-rooted schema, so legacy
// data can't silently leak into the new code paths. See
// the existing store predates the UUID-rooted schema, so legacy data
// can't silently leak into the new code paths. See
// docs/uuid-rooted-metadata.md.
if err := storageClient.EnsureSchemaVersion(storage.SchemaVersion); err != nil {
log.Fatalf("[meta-core] %v", err)
}
log.Printf("[meta-core] Redis schema version OK (v%d)", storage.SchemaVersion)
log.Printf("[meta-core] Store schema version OK (v%d)", storage.SchemaVersion)
// Beacon v2 (docs/project-architecture/beacon-v2.md): advertise meta-core
// as metamesh.core — carrying the /urls block services locate us by — plus
@@ -101,7 +86,7 @@ func main() {
return "running", []meshdisco.Resource{core, service}
},
})
if err := mesh.Start(); err != nil {
if err := mesh.Start(); err != nil {
log.Printf("[meta-core] Warning: UDP discovery disabled: %v", err)
mesh = nil
}