Add Neo4j integration tests and query rate-limiting logic
Some checks failed
Go / build-and-release (push) Has been cancelled
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user