l8bus

Virtual Network

Overlay networking with routing, health, and leader election.

Overview

L8Bus implements the Layer 8 overlay network. TCP-based virtual networking with VNet switches and VNic interfaces. Smart service routing, multicast messaging, UDP-based peer discovery, distributed health monitoring, circuit breakers, metrics collection, and dynamic plugin loading.

Routing Algorithms

The VNic provides six message delivery strategies. Each has a fire-and-forget variant and a synchronous Request variant that waits for a response.

Proximity
Routes to the nearest service instance (same VNet segment)
Round Robin
Distributes requests evenly across all instances
Local
Routes to a service instance on the local VNic only
Leader
Routes to the leader instance (earliest registered)
Unicast
Direct point-to-point delivery to a specific VNic UUID
Multicast
Broadcasts to all instances of a service

Health and Monitoring

CPU tracking via /proc/self/stat and /proc/stat
Memory tracking via runtime.MemStats.Alloc
Up/Down status per node with start time and service list
Deterministic leader election based on earliest registered participant

Circuit Breaker

Three-state pattern: Closed, Open, Half-Open. Configurable failure threshold (default 5), reset timeout (30s), concurrency limit (100), and success threshold (3) for half-open recovery.

Metrics System

Thread-safe registry for application performance tracking.

Counters
Monotonically increasing values (request counts, errors)
Gauges
Point-in-time values (active connections, queue depth)
Histograms
Value distributions (latency, message sizes)
Labels
Multi-dimensional metric tagging

Architecture

overlay/vnet/
Virtual Network Switch: TCP listener, connection pool, service registry, route tables, UDP discovery, notifications, health management (13 files, ~1,837 lines)
overlay/vnic/
Virtual Network Interface: API, routing algorithms, TX/RX, keep-alive, health stats (12 files, ~1,368 lines)
overlay/health/
Health service, leader election, CPU/memory tracking (4 files)
overlay/metrics/
Metrics collector, circuit breaker, connection health (3 files)
overlay/protocol/
Message serialization and per-service counting
overlay/plugins/
Dynamic .so plugin loading with MD5-based caching

Queue-Based Processing

Dedicated queues for service tasks, system tasks, data handling, and health reporting. Non-blocking event processing throughout.

Statistics

44 source files, roughly 5,600 lines of Go (excluding vendor and tests). 8 integration test files covering overlay, messaging, keep-alive, leader election, scaling, and external VNic scenarios.