refactor: follow the google go style guide

Document every package and exported identifier, return the log level
from NewLogger instead of keeping it in a package variable, and stop
tests from mutating the argon2 parameters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 00:18:02 +01:00
1 parent 048e114fd9
commit d20225982a
21 files changed
+147 -36

No files matched your search

+6
View File
@@ -15,12 +15,14 @@ import (
"git.zb-server.de/ZB-Server/uptimesebi/internal/migrations"
)
// Deps are the connections every command needs.
type Deps struct {
Log *slog.Logger
DB *pgxpool.Pool
Redis *redis.Client
}
// Close releases all connections. It is safe on a partially built Deps.
func (d *Deps) Close() {
if d.DB != nil {
d.DB.Close()
@@ -30,6 +32,7 @@ func (d *Deps) Close() {
}
}
// Probes returns readiness probes for the connections.
func (d *Deps) Probes() map[string]Probe {
return map[string]Probe{
"postgres": func(ctx context.Context) error { return d.DB.Ping(ctx) },
@@ -37,10 +40,13 @@ func (d *Deps) Probes() map[string]Probe {
}
}
// SignalContext is cancelled on SIGINT or SIGTERM.
func SignalContext() (context.Context, context.CancelFunc) {
return signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
}
// Connect validates c, refuses to start against an outdated schema, and
// opens Postgres and Redis.
func Connect(ctx context.Context, c config.Common, log *slog.Logger) (*Deps, error) {
if err := c.Validate(); err != nil {
return nil, err