Take into account calls during current session

pull/786/head
kompotkot 2023-05-22 11:43:28 +00:00
rodzic e199d5bb1a
commit 647cccb99f
2 zmienionych plików z 3 dodań i 3 usunięć

Wyświetl plik

@ -45,7 +45,7 @@ func (ca *ClientAccess) CheckClientCallPeriodLimits(tsNow int64) bool {
isClientAllowedToGetAccess := false
if tsNow-ca.ClientResourceData.PeriodStartTs < ca.ClientResourceData.PeriodDuration {
// Client operates in period
if ca.ClientResourceData.CallsPerPeriod < ca.ClientResourceData.MaxCallsPerPeriod {
if ca.ClientResourceData.CallsPerPeriod+ca.LastSessionCallsCounter < ca.ClientResourceData.MaxCallsPerPeriod {
// Client's limit of calls not reached
isClientAllowedToGetAccess = true
}

Wyświetl plik

@ -31,8 +31,8 @@ var (
NB_HEALTH_CHECK_CALL_TIMEOUT = time.Second * 2
NB_CACHE_CLEANING_INTERVAL = time.Second * 10
NB_CACHE_ACCESS_ID_LIFETIME = int64(120) // TODO(kompotkot): Set to 2 mins
NB_CACHE_ACCESS_ID_SESSION_LIFETIME = int64(600) // TODO(kompotkot): Set to 10 mins
NB_CACHE_ACCESS_ID_LIFETIME = int64(120) // 2 minutes
NB_CACHE_ACCESS_ID_SESSION_LIFETIME = int64(600) // 10 minutes
NB_MAX_COUNTER_NUMBER = uint64(10000000)