feat(thoth): cached ip to asn checker

Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso
2025-05-21 11:27:53 -04:00
parent 946557b378
commit 315253dce7
6 changed files with 82 additions and 2 deletions
+19
View File
@@ -4,6 +4,8 @@ import (
"fmt"
"net/http/httptest"
"testing"
iptoasnv1 "github.com/TecharoHQ/thoth-proto/gen/techaro/thoth/iptoasn/v1"
)
func TestASNChecker(t *testing.T) {
@@ -57,3 +59,20 @@ func TestASNChecker(t *testing.T) {
})
}
}
func BenchmarkWithCache(b *testing.B) {
cli := loadSecrets(b)
req := &iptoasnv1.LookupRequest{IpAddress: "1.1.1.1"}
_, err := cli.iptoasn.Lookup(b.Context(), req)
if err != nil {
b.Error(err)
}
for b.Loop() {
_, err := cli.iptoasn.Lookup(b.Context(), req)
if err != nil {
b.Error(err)
}
}
}