mirror of
https://github.com/tiennm99/keepalive.git
synced 2026-10-19 08:15:21 +00:00
fix: bound connects, write on start, and tighten config checks
- Each connect attempt, including initialization, times out after 1 minute, and PostgreSQL DSNs without connect_timeout get connect_timeout=30, since lib/pq honours the context only while dialing. - A service increments right after connecting, so a restart writes even when the interval outlasts the process. - A config path that is a directory (Docker's stand-in for a missing bind-mount source) fails with a clear message. - Generated service names take the first free suffix, and suffixed names are reserved so an explicit name cannot silently collide with them. - counter_key inside a service's config map is rejected instead of being overwritten. - Unknown keys in the config file log a warning without blocking start. - A .dockerignore keeps local configs and .env out of the build context.
This commit is contained in:
1 parent
5067966364
commit
0af652953f
9 files changed
+218
-22
No files matched your search
@@ -0,0 +1,16 @@
|
||||
package adapter
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestWithDefaultConnectTimeout(t *testing.T) {
|
||||
for _, tc := range []struct{ in, want string }{
|
||||
{"postgres://u:p@db.example.com/k", "postgres://u:p@db.example.com/k?connect_timeout=30"},
|
||||
{"postgres://u:p@db.example.com/k?sslmode=require", "postgres://u:p@db.example.com/k?sslmode=require&connect_timeout=30"},
|
||||
{"postgres://db.example.com/k?connect_timeout=5", "postgres://db.example.com/k?connect_timeout=5"},
|
||||
{"host=db.example.com dbname=k", "host=db.example.com dbname=k connect_timeout=30"},
|
||||
} {
|
||||
if got := withDefaultConnectTimeout(tc.in); got != tc.want {
|
||||
t.Fatalf("withDefaultConnectTimeout(%q) = %q, want %q", tc.in, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user