Documentation
¶
Index ¶
- type BackupInfo
- type Component
- type Config
- type GitHubAsset
- type GitHubRelease
- type Launcher
- type UpdateStatus
- type Updater
- func (u *Updater) CheckUpdate(ctx context.Context, componentName string) error
- func (u *Updater) CleanupOldBackups(maxAge time.Duration) error
- func (u *Updater) GetAllUpdateStatus() map[string]*UpdateStatus
- func (u *Updater) GetBackups() map[string]*BackupInfo
- func (u *Updater) GetComponents() []Component
- func (u *Updater) GetPendingUpdates() []Component
- func (u *Updater) GetUpdateStatus(componentName string) *UpdateStatus
- func (u *Updater) HealthCheck(ctx context.Context) error
- func (u *Updater) NeedsRestart() bool
- func (u *Updater) RegisterComponent(c Component)
- func (u *Updater) Rollback(ctx context.Context, componentName string) error
- func (u *Updater) SetGitHubToken(token string)
- func (u *Updater) SetOnRestartNeeded(fn func())
- func (u *Updater) SetOnUpdateAvailable(fn func(component, currentVersion, latestVersion string))
- func (u *Updater) SetOnUpdateComplete(fn func(component, version string))
- func (u *Updater) Start(ctx context.Context) error
- func (u *Updater) Stop()
- func (u *Updater) Update(ctx context.Context, componentName string) error
- func (u *Updater) UpdateAll(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackupInfo ¶ added in v0.0.21
type BackupInfo struct {
Component string `json:"component"`
BackupPath string `json:"backup_path"`
OriginalDir string `json:"original_dir"`
Version string `json:"version"`
CreatedAt time.Time `json:"created_at"`
}
BackupInfo stores information about a backup for rollback
type Component ¶
type Component struct {
Name string `json:"name"`
CurrentVersion string `json:"current_version"`
LatestVersion string `json:"latest_version,omitempty"`
UpdateAvail bool `json:"update_available"`
Repository string `json:"repository"`
AssetPattern string `json:"asset_pattern"` // e.g., "spatialnvr-linux-{arch}"
InstallPath string `json:"install_path"`
LastChecked time.Time `json:"last_checked"`
AutoUpdate bool `json:"auto_update"`
}
Component represents an updatable component
type Config ¶
type Config struct {
CheckInterval time.Duration `json:"check_interval"` // How often to check for updates
AutoUpdate bool `json:"auto_update"` // Enable automatic updates
AutoUpdateTime string `json:"auto_update_time"` // Time to apply auto-updates (e.g., "03:00")
IncludePrereleases bool `json:"include_prereleases"`
DataPath string `json:"data_path"` // Where to store downloaded updates
GitHubToken string `json:"github_token"` // GitHub token for private repos
ShutdownTimeout time.Duration `json:"shutdown_timeout"` // How long to wait for graceful shutdown
HealthCheckURL string `json:"health_check_url"` // URL to check after restart
HealthCheckTimeout time.Duration `json:"health_check_timeout"` // How long to wait for health check
MinDiskSpace int64 `json:"min_disk_space"` // Minimum free disk space in bytes
}
Config holds updater configuration
type GitHubAsset ¶
type GitHubAsset struct {
Name string `json:"name"`
BrowserDownloadURL string `json:"browser_download_url"`
Size int64 `json:"size"`
ContentType string `json:"content_type"`
}
GitHubAsset represents a release asset
type GitHubRelease ¶
type GitHubRelease struct {
TagName string `json:"tag_name"`
Name string `json:"name"`
Prerelease bool `json:"prerelease"`
Draft bool `json:"draft"`
PublishedAt time.Time `json:"published_at"`
Assets []GitHubAsset `json:"assets"`
}
GitHubRelease represents a GitHub release API response
type Launcher ¶
type Launcher struct {
// contains filtered or unexported fields
}
Launcher manages the NVR process lifecycle It's responsible for starting, stopping, and restarting the main NVR process
func NewLauncher ¶
NewLauncher creates a new launcher
func (*Launcher) Restart ¶
func (l *Launcher) Restart()
Restart requests a restart of the NVR process
type UpdateStatus ¶
type UpdateStatus struct {
Component string `json:"component"`
Status string `json:"status"` // checking, downloading, extracting, installing, complete, error
Progress float64 `json:"progress"`
Message string `json:"message"`
StartedAt time.Time `json:"started_at"`
CompletedAt time.Time `json:"completed_at,omitempty"`
Error string `json:"error,omitempty"`
}
UpdateStatus represents the current update status
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
Updater manages component updates
func NewUpdater ¶
NewUpdater creates a new updater instance
func (*Updater) CheckUpdate ¶
CheckUpdate checks for updates for a specific component
func (*Updater) CleanupOldBackups ¶ added in v0.0.21
CleanupOldBackups removes backups older than the specified duration
func (*Updater) GetAllUpdateStatus ¶
func (u *Updater) GetAllUpdateStatus() map[string]*UpdateStatus
GetAllUpdateStatus returns status for all components
func (*Updater) GetBackups ¶ added in v0.0.21
func (u *Updater) GetBackups() map[string]*BackupInfo
GetBackups returns available backups for all components
func (*Updater) GetComponents ¶
GetComponents returns all registered components
func (*Updater) GetPendingUpdates ¶
GetPendingUpdates returns components that have updates available
func (*Updater) GetUpdateStatus ¶
func (u *Updater) GetUpdateStatus(componentName string) *UpdateStatus
GetUpdateStatus returns the current update status for a component
func (*Updater) HealthCheck ¶ added in v0.0.21
HealthCheck verifies the system is healthy after an update
func (*Updater) NeedsRestart ¶
NeedsRestart returns true if any component was updated and needs a restart
func (*Updater) RegisterComponent ¶
RegisterComponent registers a component for update tracking
func (*Updater) SetGitHubToken ¶
SetGitHubToken updates the GitHub token dynamically
func (*Updater) SetOnRestartNeeded ¶
func (u *Updater) SetOnRestartNeeded(fn func())
SetOnRestartNeeded sets the callback for when a restart is needed after updates
func (*Updater) SetOnUpdateAvailable ¶
SetOnUpdateAvailable sets the callback for when updates are available
func (*Updater) SetOnUpdateComplete ¶
SetOnUpdateComplete sets the callback for when an update completes