Add Neo4j integration tests and query rate-limiting logic
Some checks failed
Go / build-and-release (push) Has been cancelled

Introduce comprehensive integration tests for Neo4j bug fixes covering batching, event relationships, and processing logic. Add rate-limiting to Neo4j queries using semaphores and retry policies to prevent authentication rate limiting and connection exhaustion, ensuring system stability under load.
This commit is contained in:
2025-12-07 00:07:25 +00:00
parent 8ea91e39d8
commit 95271cbc81
21 changed files with 1925 additions and 1594 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"strings"
"time"
"git.mleku.dev/mleku/nostr/encoders/event"
"git.mleku.dev/mleku/nostr/encoders/filter"
@@ -192,6 +193,16 @@ func (n *N) buildCypherQuery(f *filter.F, includeDeleteEvents bool) (string, map
whereClauses = append(whereClauses, "e.kind <> 5")
}
// Filter out expired events (NIP-40) unless querying by explicit IDs
// Events with expiration > 0 that have passed are hidden from results
// EXCEPT when the query includes specific event IDs (allowing explicit lookup)
hasExplicitIds := f.Ids != nil && len(f.Ids.T) > 0
if !hasExplicitIds {
params["now"] = time.Now().Unix()
// Show events where either: no expiration (expiration = 0) OR expiration hasn't passed yet
whereClauses = append(whereClauses, "(e.expiration = 0 OR e.expiration > $now)")
}
// Build WHERE clause
whereClause := ""
if len(whereClauses) > 0 {