fix(monitors): index heartbeat token hash
This commit is contained in:
@@ -23,6 +23,15 @@ func EnsureMonitorServerStateIndexes() error {
|
||||
if err != nil {
|
||||
log.Printf("warning: monitor_server_states indexes: %v", err)
|
||||
}
|
||||
// Every heartbeat ping looks its monitor up by token hash. Sparse because
|
||||
// only heartbeat monitors carry one.
|
||||
_, err = db.Col("monitors").Indexes().CreateOne(context.Background(), mongo.IndexModel{
|
||||
Keys: bson.D{{Key: "heartbeat_token_hash", Value: 1}},
|
||||
Options: options.Index().SetSparse(true),
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("warning: monitors heartbeat_token_hash index: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user