Add reliability improvements and config persistence feature

- Implement context cleanup with sync.Once and io.Closer interface
- Add regex-based error classification for robust error handling
- Create ProcessManager with thread-safe process tracking
- Add disk space caching with 30s TTL for performance
- Implement metrics collection with structured logging
- Add config persistence (.dbbackup.conf) for directory-local settings
- Auto-save/auto-load configuration with --no-config and --no-save-config flags
- Successfully tested with 42GB d7030 database (35K large objects, 36min backup)
- All cross-platform builds working (9/10 platforms)
This commit is contained in:
2025-11-19 04:43:22 +00:00
parent ccf70db840
commit e80c16bf0e
14 changed files with 787 additions and 13 deletions

View File

@@ -3,7 +3,9 @@ package tui
import (
"context"
"fmt"
"io"
"strings"
"sync"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
@@ -61,8 +63,9 @@ type MenuModel struct {
dbTypeCursor int
// Background operations
ctx context.Context
cancel context.CancelFunc
ctx context.Context
cancel context.CancelFunc
closeOnce sync.Once
}
func NewMenuModel(cfg *config.Config, log logger.Logger) MenuModel {
@@ -109,6 +112,19 @@ func NewMenuModel(cfg *config.Config, log logger.Logger) MenuModel {
return model
}
// Close implements io.Closer for safe cleanup
func (m *MenuModel) Close() error {
m.closeOnce.Do(func() {
if m.cancel != nil {
m.cancel()
}
})
return nil
}
// Ensure MenuModel implements io.Closer
var _ io.Closer = (*MenuModel)(nil)
// Init initializes the model
func (m MenuModel) Init() tea.Cmd {
return nil

View File

@@ -252,6 +252,12 @@ func (s *SilentLogger) Time(msg string, args ...any) {}
func (s *SilentLogger) StartOperation(name string) logger.OperationLogger {
return &SilentOperation{}
}
func (s *SilentLogger) WithFields(fields map[string]interface{}) logger.Logger {
return s
}
func (s *SilentLogger) WithField(key string, value interface{}) logger.Logger {
return s
}
// SilentOperation implements logger.OperationLogger but doesn't output anything
type SilentOperation struct{}