sync

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package sync implements the core synchronization logic between UniFi Site Manager and Snipe-IT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogFormatter

func SetLogFormatter(formatter logrus.Formatter)

SetLogFormatter sets the logger formatter.

func SetLogLevel

func SetLogLevel(level logrus.Level)

SetLogLevel sets the logger level.

func SetLogOutput

func SetLogOutput(output io.Writer)

SetLogOutput sets the logger output.

Types

type Engine

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

Engine performs the sync between UniFi and Snipe-IT.

func NewDownloadEngine

func NewDownloadEngine(unifiClient *unifi.Client, cfg *config.Config) *Engine

NewDownloadEngine creates a lightweight engine for downloading UniFi data without needing a Snipe-IT client.

func NewEngine

func NewEngine(unifiClient *unifi.Client, snipeClient *snipe.Client, cfg *config.Config) *Engine

NewEngine creates a new sync engine.

func (*Engine) CacheDir

func (e *Engine) CacheDir() string

CacheDir returns the configured cache directory, defaulting to ".cache".

func (*Engine) FetchAndSaveCache

func (e *Engine) FetchAndSaveCache(ctx context.Context) ([]unifi.FlatDevice, error)

FetchAndSaveCache fetches all devices from UniFi and writes them to cache.

func (*Engine) LoadCache

func (e *Engine) LoadCache() error

LoadCache reads UniFi cache from JSON files in the cache directory.

func (*Engine) Run

func (e *Engine) Run(ctx context.Context) (*Stats, error)

Run executes the full sync process.

func (*Engine) RunSingle

func (e *Engine) RunSingle(ctx context.Context, mac string) (*Stats, error)

RunSingle syncs a single device identified by MAC address.

type Stats

type Stats struct {
	Total    int
	Created  int
	Updated  int
	Skipped  int
	Errors   int
	ModelNew int
}

Stats tracks sync operation counts.

Jump to

Keyboard shortcuts

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