list by pages and rate req limits

This commit is contained in:
Gitea
2023-12-15 13:00:59 +03:00
parent 2f3a6e35e9
commit 06c7997491
10 changed files with 204 additions and 116 deletions

View File

@ -34,6 +34,10 @@ func LogError(ctx context.Context, log *slog.Logger, msg string, attrs ...slog.A
log.LogAttrs(ctx, slog.LevelError, msg, append(attrs, getLogFields(ctx)...)...)
}
func LogWithWarnError(ctx context.Context, log *slog.Logger, err error, msg string, attrs ...slog.Attr) {
LogWarn(ctx, log, msg, append(attrs, slog.Any("err", err))...)
}
func LogWithError(ctx context.Context, log *slog.Logger, err error, msg string, attrs ...slog.Attr) {
LogError(ctx, log, msg, append(attrs, slog.Any("err", err))...)
}

View File

@ -0,0 +1,15 @@
package xcontext
import (
"context"
"time"
)
func Wait(ctx context.Context, wait time.Duration) error {
select {
case <-ctx.Done():
return ctx.Err()
case <-time.After(wait):
return nil
}
}