l8inventory

Inventory

Distributed cache for parsed infrastructure data.

Overview

A high-performance, generic, and model-agnostic distributed inventory cache for collected and parsed data. Works with any data model through Protocol Buffers. Supports network devices, Kubernetes resources, and custom inventory types. Built on the Layer 8 distributed cache infrastructure with SQL-like query capabilities.

Core Components

InventoryService
Layer 8 service handler implementing full CRUD operations, aggregator-based forwarding, and web service endpoint registration.
InventoryCenter
Core engine wrapping a DistributedCache with queries, pagination, metadata functions, and primary key lookups.
InventoryUtils
Helpers including placeholder element creation via reflection.

Data Flow

Upstream clients (REST API, Layer 8 services) send CRUD operations to the InventoryService. Data is stored in a local in-memory cache. When forwarding is configured, an Aggregator batches operations and sends them to a downstream persistence service (ORM).

Operations

POST
Add new inventory items
PUT
Replace existing items
PATCH
Partial update of existing items
DELETE
Remove items
GET
Query with SQL-like syntax and pagination, or single-element lookup by primary key

All write operations support optional forwarding to a downstream persistence service. Notifications (replicated operations from other nodes) are not forwarded, preventing duplicate writes.

Forwarding Architecture

When activated with a linksId, the service creates an Aggregator that batches operations (5 elements per flush, 30-second interval) and forwards them to the persistence service resolved via targets.Links.Persist(linksId).

Query Interface

SQL-like queries via L8Query: select * from Device where status=1. Supports filtering, pagination, and custom metadata functions. Metadata functions are evaluated per element during queries to compute aggregated values (e.g., status counts).

Key Features

Generic -- works with any protobuf model
Distributed -- built on Layer 8 distributed cache with service link support
Configurable primary keys per data type
REST API via web service endpoint with L8Query-based GET
Extensible metadata via AddMetadata function
Placeholder element creation for pre-allocation