aggregator

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureSchema

func EnsureSchema(db *sql.DB, expectedDB string) error

EnsureSchema checks that the connection targets the expected database and creates any missing tables.

func OpenDatabase

func OpenDatabase(cfg pq.Config) (*sql.DB, error)

OpenDatabase creates and verifies a connection to the PostgreSQL database using the provided pq.Config.

func Run

func Run(ctx context.Context, cfg Config) error

Run starts the inventory collector service.

func UpsertDevices

func UpsertDevices(ctx context.Context, db *sql.DB, records []*inventoryv1.DeviceRecord) (int, error)

UpsertDevices inserts or updates device records into the PostgreSQL inventory table. Conflicts on serial_number trigger an update when any mutable column differs.

func UpsertNeighbors

func UpsertNeighbors(ctx context.Context, db *sql.DB, records []*inventoryv1.NeighborRecord) (int, error)

UpsertNeighbors inserts or updates neighbor records into the PostgreSQL neighbors table. Conflicts on (host_identifier, local_interface) trigger an update when attributes differ.

Types

type Config

type Config struct {
	Debug    bool
	DbConn   pq.Config
	GRPCAddr string
}

Config holds the configuration for the inventory collector service.

type Server

type Server struct {
	inventoryv1.UnimplementedInventoryAggregatorServer
	// contains filtered or unexported fields
}

Server implements the InventoryAggregator gRPC service.

func NewServer

func NewServer(db *sql.DB) *Server

NewServer returns a new gRPC server backed by the given database connection.

func (*Server) SubmitInventory

SubmitInventory receives a batch of device and neighbor records and persists them to the PostgreSQL database.

Jump to

Keyboard shortcuts

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