forked from mtusi2026/mtusi2026lab2
Начало реализации сервиса.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package inmemory
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"gitea.privcloud.tech/mtusi2026/internal/pkg/apperr"
|
||||
)
|
||||
|
||||
func pageLimit(rawLimit *int) (int, error) {
|
||||
limit := 50
|
||||
if rawLimit != nil {
|
||||
limit = *rawLimit
|
||||
}
|
||||
if limit < 1 || limit > 100 {
|
||||
return 0, apperr.New(apperr.CodeInvalidRequest, "invalid limit")
|
||||
}
|
||||
return limit, nil
|
||||
}
|
||||
|
||||
func lessKey(leftTime time.Time, leftID uuid.UUID, rightTime time.Time, rightID uuid.UUID) bool {
|
||||
if !leftTime.Equal(rightTime) {
|
||||
return leftTime.Before(rightTime)
|
||||
}
|
||||
return bytes.Compare(leftID[:], rightID[:]) < 0
|
||||
}
|
||||
Reference in New Issue
Block a user