l8utils

Utilities

Shared utilities: logging, caching, configuration.

Overview

L8Utils provides the shared building blocks used across all Layer 8 services. High-performance cache, priority queues, async logging, thread-safe maps, type registry, notifications, and a centralized resource container. All components are interface-driven and thread-safe.

Cache

In-memory cache with optional storage persistence. Supports CRUD, paginated queries with 30-second TTL, clone-based isolation, statistics tracking, and collection operations.

Post, Get, Put, Patch, Delete with optional notification
Dry-run Patch for optimized updates
Named stat functions with automatic totals
Query cache with configurable TTL and background cleanup

Queues

Two queue implementations optimized for different workloads.

ByteQueue
8 priority levels with O(1) bit operations. Blocking and non-blocking dequeue.
Queue
Generic queue for any type. Optional no-limit mode for unbounded workloads.

Logging

Async, queue-based logging framework with a 50,000-entry buffer. Supports file output with configurable directory, console output, or both. Five log levels: Trace, Debug, Info, Warning, Error. Includes pprof integration for CPU and heap profiling. Direct (synchronous) logger also available.

Notifications

Distributed state change notification system. Supports Add, Delete, Update, Replace, and Sync types plus TSDB notifications for time-series data. Property-level change granularity with sequence numbering and service-area routing.

Registry

Type registration and dynamic instance creation. Enum registration and management. Layer 8 core types pre-registered. Thread-safe operations via sync.RWMutex.

Additional Components

Resources
Centralized dependency injection container (logger, registry, security, serializers, config, services)
SyncMap
Thread-safe map with reflection-based type-safe value/key lists
Workers
Worker pool with configurable concurrency limits and condition-variable coordination
Certificates
TLS/SSL certificate utilities with self-signed certificate support
Strings
Type-safe string-to-primitive conversions, formatting, escape handling
Aggregator
Data aggregation utilities for collection processing
Web
RESTful service utilities with protocol buffer integration

Project Structure

go/utils/cache/
Cache with storage integration
go/utils/queues/
Priority queue implementations
go/utils/logger/
Async logging with pprof support
go/utils/notify/
Notification system
go/utils/registry/
Type registration
go/utils/resources/
Centralized resource container
go/utils/maps/
Thread-safe SyncMap
go/utils/workers/
Worker pool

Design Principles

Interface-driven: all components expose interfaces from l8types
Thread-safe: sync.RWMutex, sync.Cond, or sync.Map throughout
Clone-based isolation: cache returns clones to prevent external mutation
Async processing: logger and cache use background goroutines
No file exceeds 500 lines