2024-11-15 13:39:23: merge [main:ac1457e534d62c78d515db685ff817ffd1998a06];
This commit is contained in:
1 parent
daf35df301
commit
f8074400a1
12 files changed
+141
-172
No files matched your search
+5
-5
@@ -49,9 +49,9 @@ type Auth struct {
|
||||
sudirService sudirService
|
||||
auditService auditService
|
||||
logger log.Logger
|
||||
maxInFlightLoginRequests int
|
||||
maxInFlightLoginRequests int64
|
||||
delayLoginRequest time.Duration
|
||||
inFlightLoginRequests *atomic.Int32
|
||||
inFlightLoginRequests *atomic.Int64
|
||||
}
|
||||
|
||||
func NewAuth(
|
||||
@@ -72,8 +72,8 @@ func NewAuth(
|
||||
auditService: auditService,
|
||||
logger: logger,
|
||||
delayLoginRequest: time.Duration(delayLoginRequestInSec) * time.Second,
|
||||
maxInFlightLoginRequests: maxInFlightLoginRequests,
|
||||
inFlightLoginRequests: &atomic.Int32{},
|
||||
maxInFlightLoginRequests: int64(maxInFlightLoginRequests),
|
||||
inFlightLoginRequests: &atomic.Int64{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ func (a Auth) Login(ctx context.Context, request domain.LoginRequest) (*domain.L
|
||||
value := a.inFlightLoginRequests.Add(1)
|
||||
defer a.inFlightLoginRequests.Add(-1)
|
||||
|
||||
if value > int32(a.maxInFlightLoginRequests) {
|
||||
if value > a.maxInFlightLoginRequests {
|
||||
return nil, domain.ErrTooManyLoginRequests
|
||||
}
|
||||
time.Sleep(a.delayLoginRequest)
|
||||
|
||||
Reference in new issue
Block a user