2026-10-12 12:27:14: merge [main:43ce9babe5667b4aa643ec333e1b8e988c1a8980];
This commit is contained in:
1 parent
17985317d2
commit
4b9d03c833
21 files changed
+595
-243
No files matched your search
@@ -5,8 +5,9 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"isp-lock-service/domain"
|
||||
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
)
|
||||
|
||||
type dailyLimiterRepo interface {
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
type LockerRepo interface {
|
||||
Lock(ctx context.Context, key string, ttlInSec int) (*domain.LockResponse, error)
|
||||
TryLock(ctx context.Context, key string, ttlInSec int) (*domain.LockResponse, error)
|
||||
UnLock(ctx context.Context, key, lockKey string) (*domain.LockResponse, error)
|
||||
}
|
||||
|
||||
@@ -30,6 +31,11 @@ func (l Locker) Lock(ctx context.Context, req domain.LockRequest) (*domain.LockR
|
||||
return l.repo.Lock(ctx, req.Key, req.TTLInSec)
|
||||
}
|
||||
|
||||
func (l Locker) TryLock(ctx context.Context, req domain.LockRequest) (*domain.LockResponse, error) {
|
||||
// nolint: wrapcheck
|
||||
return l.repo.TryLock(ctx, req.Key, req.TTLInSec)
|
||||
}
|
||||
|
||||
func (l Locker) UnLock(ctx context.Context, req domain.UnLockRequest) (*domain.LockResponse, error) {
|
||||
// nolint: wrapcheck
|
||||
return l.repo.UnLock(ctx, req.Key, req.LockKey)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
type limiterRepo interface {
|
||||
Limit(ctx context.Context, key string, maxRps int) (*domain.RateLimiterResponse, error)
|
||||
Limit(ctx context.Context, req domain.RateLimiterRequest) (*domain.RateLimiterResponse, error)
|
||||
LimitInMem(ctx context.Context, key string, maxRps float64, infiniteKey bool) (*domain.RateLimiterInMemResponse, error)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ func NewRateLimiter(repo limiterRepo) rateLimiter {
|
||||
}
|
||||
|
||||
func (s rateLimiter) Limit(ctx context.Context, req domain.RateLimiterRequest) (*domain.RateLimiterResponse, error) {
|
||||
return s.repo.Limit(ctx, req.Key, req.MaxRps) // nolint:wrapcheck
|
||||
return s.repo.Limit(ctx, req) // nolint:wrapcheck
|
||||
}
|
||||
|
||||
func (s rateLimiter) LimitInMem(ctx context.Context, req domain.RateLimiterInMemRequest) (*domain.RateLimiterInMemResponse, error) {
|
||||
|
||||
Reference in new issue
Block a user