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:
tiennm99 committed 2026-10-09 11:15:59 +07:00
1 parent 5067966364
commit 0af652953f
9 files changed
+218 -22

No files matched your search

+16
View File
@@ -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)
}
}
}