Documentation
¶
Overview ¶
Package daemon provides long-running background sync functionality.
Index ¶
- type Config
- type ControlResponse
- type Daemon
- type Status
- type StatusTracker
- func (st *StatusTracker) GetStatus() Status
- func (st *StatusTracker) SetError(err error)
- func (st *StatusTracker) SetNextSyncTime(t time.Time)
- func (st *StatusTracker) SetState(state SyncState)
- func (st *StatusTracker) SyncCompleted(summary SyncSummary)
- func (st *StatusTracker) SyncFailed(err error, duration time.Duration)
- func (st *StatusTracker) SyncStarted(totalDocs int)
- func (st *StatusTracker) UpdateProgress(processed int, currentDoc, stage string)
- type SyncProgress
- type SyncState
- type SyncSummary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Orchestrator *sync.Orchestrator
Logger *logger.Logger
SyncInterval time.Duration // How often to sync (default: 5 minutes)
HealthCheckAddr string // Optional health check address (e.g. ":8080")
PIDFile string // Optional PID file path
}
Config holds configuration for the daemon
type ControlResponse ¶ added in v1.3.0
type ControlResponse struct {
Success bool `json:"success"`
Message string `json:"message"`
Error string `json:"error,omitempty"`
}
ControlResponse is the standard response for control API calls
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon manages periodic synchronization in the background
type Status ¶ added in v1.3.0
type Status struct {
// State is the current sync state (idle, syncing, error)
State SyncState `json:"state"`
// LastSyncTime is the timestamp of the last sync attempt
LastSyncTime *time.Time `json:"last_sync_time,omitempty"`
// NextSyncTime is the estimated time of the next sync
NextSyncTime *time.Time `json:"next_sync_time,omitempty"`
// SyncDuration is how long the last sync took
SyncDuration *time.Duration `json:"sync_duration,omitempty"`
// ErrorMessage contains the error from the last failed sync
ErrorMessage string `json:"error_message,omitempty"`
// CurrentSync contains information about an in-progress sync
CurrentSync *SyncProgress `json:"current_sync,omitempty"`
// LastSyncResult contains the result of the last completed sync
LastSyncResult *SyncSummary `json:"last_sync_result,omitempty"`
// UptimeSeconds is how long the daemon has been running
UptimeSeconds int64 `json:"uptime_seconds"`
}
Status represents the current daemon status
type StatusTracker ¶ added in v1.3.0
type StatusTracker struct {
// contains filtered or unexported fields
}
StatusTracker tracks the daemon's current status in a thread-safe manner
func NewStatusTracker ¶ added in v1.3.0
func NewStatusTracker() *StatusTracker
NewStatusTracker creates a new status tracker
func (*StatusTracker) GetStatus ¶ added in v1.3.0
func (st *StatusTracker) GetStatus() Status
GetStatus returns the current status
func (*StatusTracker) SetError ¶ added in v1.3.0
func (st *StatusTracker) SetError(err error)
SetError records an error state
func (*StatusTracker) SetNextSyncTime ¶ added in v1.3.0
func (st *StatusTracker) SetNextSyncTime(t time.Time)
SetNextSyncTime updates when the next sync is scheduled
func (*StatusTracker) SetState ¶ added in v1.3.0
func (st *StatusTracker) SetState(state SyncState)
SetState updates the current state
func (*StatusTracker) SyncCompleted ¶ added in v1.3.0
func (st *StatusTracker) SyncCompleted(summary SyncSummary)
SyncCompleted records a successful sync completion
func (*StatusTracker) SyncFailed ¶ added in v1.3.0
func (st *StatusTracker) SyncFailed(err error, duration time.Duration)
SyncFailed records a failed sync
func (*StatusTracker) SyncStarted ¶ added in v1.3.0
func (st *StatusTracker) SyncStarted(totalDocs int)
SyncStarted records the start of a sync operation
func (*StatusTracker) UpdateProgress ¶ added in v1.3.0
func (st *StatusTracker) UpdateProgress(processed int, currentDoc, stage string)
UpdateProgress updates the current sync progress
type SyncProgress ¶ added in v1.3.0
type SyncProgress struct {
// StartTime is when the current sync started
StartTime time.Time `json:"start_time"`
// DocumentsTotal is the total number of documents to process
DocumentsTotal int `json:"documents_total"`
// DocumentsProcessed is how many documents have been processed so far
DocumentsProcessed int `json:"documents_processed"`
// CurrentDocument is the document currently being processed
CurrentDocument string `json:"current_document,omitempty"`
// Stage is the current stage of processing (downloading, converting, ocr, enhancing)
Stage string `json:"stage,omitempty"`
}
SyncProgress tracks the progress of an in-progress sync operation
type SyncState ¶ added in v1.3.0
type SyncState string
SyncState represents the current state of the daemon sync process
type SyncSummary ¶ added in v1.3.0
type SyncSummary struct {
// StartTime is when the sync started
StartTime time.Time `json:"start_time"`
// EndTime is when the sync completed
EndTime time.Time `json:"end_time"`
// Duration is how long the sync took
Duration time.Duration `json:"duration"`
// TotalDocuments is the total number of documents checked
TotalDocuments int `json:"total_documents"`
// ProcessedDocuments is how many documents were processed
ProcessedDocuments int `json:"processed_documents"`
// SuccessCount is how many documents succeeded
SuccessCount int `json:"success_count"`
// FailureCount is how many documents failed
FailureCount int `json:"failure_count"`
// SkippedCount is how many documents were skipped (no changes)
SkippedCount int `json:"skipped_count"`
}
SyncSummary contains a summary of a completed sync operation