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:
@@ -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
|
||||
|
||||
@@ -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{}
|
||||
|
||||
Reference in New Issue
Block a user