lab2: postgres, sessions, redis, persistence, stale read

This commit is contained in:
2026-10-09 21:30:36 +03:00
parent 65003b6119
commit d8842a3de4
54 changed files with 3205 additions and 19 deletions
+23
View File
@@ -0,0 +1,23 @@
package service
import (
"crypto/rand"
"fmt"
"time"
)
func newID() string {
var b [16]byte
if _, err := rand.Read(b[:]); err != nil {
panic(fmt.Sprintf("crypto/rand failed: %v", err))
}
b[6] = (b[6] & 0x0f) | 0x40
b[8] = (b[8] & 0x3f) | 0x80
return fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:16])
}
// nowUTC возвращает время UTC с точностью до секунд.
// PostgreSQL и Python-клиент тестов ожидают формат без наносекунд.
func nowUTC() time.Time {
return time.Now().UTC().Truncate(time.Second)
}