Documentation
¶
Overview ¶
Package sync orchestrates data synchronization from PeeringDB into the local SQLite database using the ent ORM.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitStatusTable ¶
InitStatusTable creates the sync_status table if it doesn't exist. This is not an ent-managed entity; it stores operational metadata via raw SQL.
func RecordSyncComplete ¶
RecordSyncComplete updates the sync status row with results.
Types ¶
type SyncStatus ¶
type SyncStatus struct {
LastSyncAt time.Time
Duration time.Duration
ObjectCounts map[string]int // type -> count
Status string // "success", "failed", "running"
ErrorMessage string // empty on success
}
SyncStatus represents the result of a sync operation.
func GetLastSyncStatus ¶
GetLastSyncStatus returns the most recent sync status. Returns nil if no sync has been recorded.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker orchestrates PeeringDB data synchronization.
func NewWorker ¶
func NewWorker(pdbClient *peeringdb.Client, entClient *ent.Client, db *sql.DB, cfg WorkerConfig, logger *slog.Logger) *Worker
NewWorker creates a new sync worker.
func (*Worker) HasCompletedSync ¶
HasCompletedSync reports whether at least one successful sync has completed. Used for 503 behavior per D-30.
func (*Worker) SetRetryBackoffs ¶
SetRetryBackoffs overrides the default retry backoff durations. Intended for testing.
func (*Worker) StartScheduler ¶
StartScheduler runs periodic sync via time.Ticker per D-22. It runs an initial sync immediately, then syncs on each tick. The scheduler stops when ctx is cancelled per CC-2.
type WorkerConfig ¶
WorkerConfig holds configuration for the sync worker.