mirror of
https://github.com/tiennm99/keepalive.git
synced 2026-10-11 03:13:31 +00:00
fix(runner): retry failed services after one minute and fail fast on bad config
A failed connect or tick now closes the connection and reconnects after one minute, re-running initialization so a dropped table or row is recreated. Before, a failing tick logged every interval forever and connect retries logged every 10 seconds. Connection URLs that fail to parse no longer appear in logs, since their error repeats the password. An unknown adapter or a missing required config key now stops keepalive at startup instead of silently idling one service.
This commit is contained in:
1 parent
30fd62a46c
commit
42c8a871cf
5 files changed
+168
-32
No files matched your search
@@ -196,3 +196,21 @@ func TestNormalizeConfigRejectsNonPositiveInterval(t *testing.T) {
|
||||
t.Fatal("normalizeConfig returned nil error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeConfigRejectsUnknownAdapter(t *testing.T) {
|
||||
_, err := normalizeConfig(appConfig{Services: []serviceFileConfig{
|
||||
{Adapter: "valkey", Config: map[string]string{"url": "redis://cache.example.com:6379"}},
|
||||
}})
|
||||
if err == nil || !strings.Contains(err.Error(), "services[0]") || !strings.Contains(err.Error(), "unknown adapter") {
|
||||
t.Fatalf("err = %v, want unknown adapter error for services[0]", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeConfigRejectsMissingAdapterConfigKey(t *testing.T) {
|
||||
_, err := normalizeConfig(appConfig{Services: []serviceFileConfig{
|
||||
{Adapter: "mongodb", Config: map[string]string{"uri": "mongodb://db.example.com", "database": "keepalive"}},
|
||||
}})
|
||||
if err == nil || !strings.Contains(err.Error(), "collection") {
|
||||
t.Fatalf("err = %v, want missing collection error", err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user