forked from mtusi2026/mtusi2026lab6
feat: add bounded observability and verified SLO incident alerts
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package memory
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"gitea.privcloud.tech/vlad_marlo/mtusi2026lab6/internal/model/dto"
|
||||
)
|
||||
|
||||
// timestamp is called under the write lock, keeping append order during clock rollback.
|
||||
func (s *Store) timestamp() time.Time {
|
||||
now := time.Now().UTC()
|
||||
if !now.After(s.lastTime) {
|
||||
now = s.lastTime.Add(time.Nanosecond)
|
||||
}
|
||||
s.lastTime = now
|
||||
return now
|
||||
}
|
||||
|
||||
// after compares a record with a keyset pagination position.
|
||||
func after(t time.Time, id uuid.UUID, p dto.PositionDTO) bool {
|
||||
return t.After(p.CreatedAt) || (t.Equal(p.CreatedAt) && bytes.Compare(id[:], p.ID[:]) > 0)
|
||||
}
|
||||
Reference in New Issue
Block a user