feat: use a in memory map to count requests for ips and log the n most active each hour

This commit is contained in:
crapStone 2025-06-13 23:18:01 +02:00 committed by crapStone
parent abc9bca5c4
commit f7018efcc3
7 changed files with 74 additions and 20 deletions

View file

@ -3,6 +3,7 @@ package handler
import (
"net/http"
"net/http/httptest"
"sync"
"testing"
"time"
@ -29,7 +30,7 @@ func TestHandlerPerformance(t *testing.T) {
AllowedCorsDomains: []string{"raw.codeberg.org", "fonts.codeberg.org", "design.codeberg.org"},
PagesBranches: []string{"pages"},
}
testHandler := Handler(serverCfg, giteaClient, cache.NewInMemoryCache(), cache.NewInMemoryCache())
testHandler := Handler(serverCfg, giteaClient, cache.NewInMemoryCache(), cache.NewInMemoryCache(), &sync.Map{})
testCase := func(uri string, status int) {
t.Run(uri, func(t *testing.T) {