Documentation
¶
Index ¶
- func CheckDuplicateEvent(ctx context.Context, evt nostr.Event) (bool, error)
- func DisconnectDB(client *mongo.Client)
- func EnsureIndexes(client *mongo.Client, databaseName string) error
- func GetAllAuthorsFromRelay(cfg *cfgType.ServerConfig) []string
- func GetClient() *mongo.Client
- func GetCollection(kind int) *mongo.Collection
- func GetDatabaseName() string
- func InitDB(cfg *cfgType.ServerConfig) (*mongo.Client, error)
- func InitDBSilent(cfg *cfgType.ServerConfig) (*mongo.Client, error)
- func InitDBWithRetry(cfg *cfgType.ServerConfig, maxRetries int, baseDelay, timeout time.Duration) (*mongo.Client, error)
- func InitializeDatabase(cfg *cfgType.ServerConfig) (*mongo.Client, bool)
- func IsClientHealthy(ctx context.Context) bool
- func PurgeOldEventsOptimized(cfg *cfgType.EventPurgeConfig)
- func QueryEvents(filters []nostr.Filter, client *mongo.Client, databaseName string) ([]nostr.Event, error)
- func ScheduleEventPurgingOptimized(cfg *cfgType.ServerConfig)
- func SetGlobalClient(newClient *mongo.Client, dbName string) error
- func StartMongoHealthMonitor(cfg *cfgType.ServerConfig)
- func StoreMongoEvent(ctx context.Context, evt nostr.Event, client nostr.ClientInterface)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckDuplicateEvent ¶
CheckDuplicateEvent checks if an event with the same ID already exists in the collection. Returns (isDuplicate, error) where error indicates a system error, not a duplicate.
func DisconnectDB ¶
DisconnectDB safely disconnects from MongoDB
func EnsureIndexes ¶
EnsureIndexes creates necessary indexes on all collections
func GetAllAuthorsFromRelay ¶
func GetAllAuthorsFromRelay(cfg *cfgType.ServerConfig) []string
GetAllAuthorsFromRelay fetches all unique authors from MongoDB.
func GetCollection ¶
func GetCollection(kind int) *mongo.Collection
func GetDatabaseName ¶
func GetDatabaseName() string
GetDatabaseName returns the database name from config
func InitDB ¶
func InitDB(cfg *cfgType.ServerConfig) (*mongo.Client, error)
InitDB establishes a connection to MongoDB with retry logic and graceful error handling
func InitDBSilent ¶ added in v0.4.11
func InitDBSilent(cfg *cfgType.ServerConfig) (*mongo.Client, error)
InitDBSilent attempts to connect to MongoDB without logging errors Useful for health checks where failures are expected
func InitDBWithRetry ¶ added in v0.4.11
func InitDBWithRetry(cfg *cfgType.ServerConfig, maxRetries int, baseDelay, timeout time.Duration) (*mongo.Client, error)
InitDBWithRetry establishes a MongoDB connection with configurable retry logic
func InitializeDatabase ¶ added in v0.4.11
func InitializeDatabase(cfg *cfgType.ServerConfig) (*mongo.Client, bool)
InitializeDatabase attempts to connect to MongoDB with graceful fallback
func IsClientHealthy ¶ added in v0.4.1
IsClientHealthy checks if the MongoDB client is available and connected
func PurgeOldEventsOptimized ¶
func PurgeOldEventsOptimized(cfg *cfgType.EventPurgeConfig)
PurgeOldEventsOptimized removes old events using cached whitelist data for bulk operations
func QueryEvents ¶
func QueryEvents(filters []nostr.Filter, client *mongo.Client, databaseName string) ([]nostr.Event, error)
QueryEvents queries events from the MongoDB collection(s) based on filters
func ScheduleEventPurgingOptimized ¶
func ScheduleEventPurgingOptimized(cfg *cfgType.ServerConfig)
ScheduleEventPurgingOptimized runs the optimized event purging at configurable intervals
func SetGlobalClient ¶ added in v0.4.11
SetGlobalClient safely sets the global MongoDB client (used for reconnection)
func StartMongoHealthMonitor ¶ added in v0.4.11
func StartMongoHealthMonitor(cfg *cfgType.ServerConfig)
StartMongoHealthMonitor runs background MongoDB health monitoring and reconnection
func StoreMongoEvent ¶
StoreMongoEvent processes and stores an event based on its kind
Types ¶
This section is empty.