sync

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveManifest

func SaveManifest(cacheDir string, m *Manifest) error

SaveManifest persists the inventory sync manifest atomically.

Types

type CompiledState

type CompiledState struct {
	Path         string    `json:"path"`
	EntryCount   int       `json:"entry_count"`
	PackageCount int       `json:"package_count"`
	BuiltAt      time.Time `json:"built_at,omitempty"`
}

type Config

type Config struct {
	CacheDir    string
	UserAgent   string
	Timeout     time.Duration
	SourceURL   string
	MinInterval time.Duration
	// contains filtered or unexported fields
}

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func NewEngine

func NewEngine(cfg Config) *Engine

func (*Engine) LoadIndex

func (*Engine) StartBackground

func (e *Engine) StartBackground(ctx context.Context)

func (*Engine) StatusSnapshot

func (e *Engine) StatusSnapshot() Status

func (*Engine) Wait

func (e *Engine) Wait()

Wait blocks until background refreshes scheduled through the default scheduler have finished. Each refresh is bounded by the configured Timeout, so this returns promptly when nothing is in flight and cannot hang on a slow upstream.

type Manifest

type Manifest struct {
	SchemaVersion int           `json:"schema_version"`
	Source        string        `json:"source"`
	ETag          string        `json:"etag,omitempty"`
	GeneratedAt   time.Time     `json:"generated_at,omitempty"`
	Compiled      CompiledState `json:"compiled"`
	Sync          SyncState     `json:"sync"`
}

Manifest tracks the state of the local malicious-package inventory: the upstream revision (ETag + generated_at) last ingested and the compiled index built from it.

func LoadManifest

func LoadManifest(cacheDir, source string) (*Manifest, error)

LoadManifest reads the inventory sync manifest, returning a fresh one when absent or unparsable.

type Status

type Status struct {
	Source      string    `json:"source"`
	State       string    `json:"state"`
	LastSuccess time.Time `json:"last_success,omitempty"`
	Pending     int       `json:"pending"`
	Packages    int       `json:"packages"`
	LastError   string    `json:"last_error,omitempty"`
}

type SyncState

type SyncState struct {
	State       string    `json:"state"`
	LastSuccess time.Time `json:"last_success,omitempty"`
	LastAttempt time.Time `json:"last_attempt,omitempty"`
	LastError   string    `json:"last_error,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL