host

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FoldHosts added in v0.3.0

func FoldHosts(ctx context.Context, gdb *gorm.DB, candidates *[]*pb.Host, in []*pb.Host) ([]*pb.Host, error)

FoldHosts folds `in` into the shared host table against the caller-maintained candidate set *candidates, persisting via gdb (which may be a transaction). It matches/merges/inserts exactly as IngestHosts does — identical host.SameHost / host.MergeHost semantics — but reuses the passed candidate set instead of reloading it, and appends every row it persists (a brand-new host, or an already-present one it enriched) back into *candidates, so a later FoldHosts against the same set unifies with it in memory. This is what lets a batch of runs unify their shared hosts across the batch (cross-run host-row unification) without reloading the growing host tree per run. Returns the persisted rows for THIS batch (with DB-assigned IDs), for the caller to link via its own join.

FoldHosts does NOT open a transaction of its own (unlike IngestHosts): it runs inside the caller's gdb so the caller controls the transaction boundary — e.g. scan.persistRun folds within the run's transaction, keeping each run atomic and independent.

func IngestHosts

func IngestHosts(ctx context.Context, gdb *gorm.DB, in []*pb.Host) ([]*pb.Host, error)

IngestHosts folds the given hosts into the shared host table non-destructively — the same additive, idempotent merge Upsert performs (host.MergeHost / host.SameHost) — and returns the persisted rows, each carrying its DB-assigned ID. It is the entry point other domains use to unify the hosts they observed with the global host records: a scan Run, for instance, folds its hosts through here and then links the returned shared rows via its own join table, rather than inserting a private copy of every host per run. The passed *gorm.DB may be a transaction, so the caller's own writes and this fold commit or roll back together.

func LoadHostCandidates added in v0.3.0

func LoadHostCandidates(ctx context.Context, gdb *gorm.DB, in []*pb.Host) ([]*pb.Host, error)

LoadHostCandidates loads the stored hosts that could match any host in `in` (the merge candidates), as PB values with the full tree the merge reads — the same narrowed candidate set IngestHosts loads internally (loadCandidateHostsPB). It exists so a caller folding SEVERAL batches against ONE shared candidate set (scan Create/Upsert folding many runs' hosts) can load the union of all batches ONCE up front, then thread the set through FoldHosts per batch — instead of paying loadCandidateHostsPB's DB reload once per batch (the cross-run ingest amplifier). The passed *gorm.DB may be a transaction. Over-loading is safe: FoldHosts still runs the exact SameHost matcher against the set.

func New

func New(db *gorm.DB) *server

New returns a new database host server, from a given db.

func NewUsers

func NewUsers(db *gorm.DB) *userServer

func WithPreloads

func WithPreloads(from *hosts.HostFilters) (clauses map[string]bool)

WithPreloads returns a map DB clauses, to dynamically load child struct fields.

Types

This section is empty.

Jump to

Keyboard shortcuts

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