Исправить замечания ревью кода: убрать повтор в AppendOnce за счёт запаса у чистки ключей, вынести MessagePayload и SameContent, принять X-Request-Id от балансировщика, упростить фоновые задачи сервера, сократить комментарии
This commit is contained in:
+3
-12
@@ -1,6 +1,5 @@
|
||||
// Command migrate applies the embedded schema migrations once and exits. It
|
||||
// runs as a one-shot service before the API replicas start, so the replicas
|
||||
// never race each other over the schema and need no rights to change it.
|
||||
// Command migrate applies the embedded schema migrations once and exits, so
|
||||
// the API replicas never race each other over the schema.
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -24,7 +23,7 @@ func main() {
|
||||
fmt.Fprintln(os.Stderr, "configuration error:", err)
|
||||
os.Exit(2)
|
||||
}
|
||||
log := newLogger(cfg)
|
||||
log := cfg.NewLogger()
|
||||
|
||||
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGINT)
|
||||
defer stop()
|
||||
@@ -48,11 +47,3 @@ func run(ctx context.Context, log *slog.Logger, cfg config.Migrate) error {
|
||||
log.Info("migrations applied", "applied_migrations", applied)
|
||||
return nil
|
||||
}
|
||||
|
||||
func newLogger(cfg config.Migrate) *slog.Logger {
|
||||
opts := &slog.HandlerOptions{Level: cfg.LogLevel}
|
||||
if cfg.Env == "dev" {
|
||||
return slog.New(slog.NewTextHandler(os.Stdout, opts))
|
||||
}
|
||||
return slog.New(slog.NewJSONHandler(os.Stdout, opts))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user