feat(audit): flush audit logs into DB in a standalone goroutine

This commit is contained in:
Aaron Liu
2025-08-12 13:10:46 +08:00
parent 5f18d277c8
commit bb9b42eb10
3 changed files with 32 additions and 3 deletions

View File

@@ -164,6 +164,14 @@ func (s *server) Start() error {
}
func (s *server) Close() {
// Close audit recorder first to ensure all logs are persisted
if s.auditRecorder != nil {
s.logger.Info("Closing audit recorder...")
if err := s.auditRecorder.Close(); err != nil {
s.logger.Error("Failed to close audit recorder: %s", err)
}
}
if s.dbClient != nil {
s.logger.Info("Shutting down database connection...")
if err := s.dbClient.Close(); err != nil {