@aurora/runtime-core (0.3.3)
Published 2025-12-27 10:44:37 +00:00 by vlad
Installation
@aurora:registry=npm install @aurora/runtime-core@0.3.3"@aurora/runtime-core": "0.3.3"About this package
@aurora/runtime-core
Core runtime utilities for Aurora framework, including node identity and metadata management for multi-node deployments.
Installation
bun add @aurora/runtime-core
Features
- NodeIdentity: Unique identification for Aurora nodes in multi-node deployments
- Auto-generated UUIDs for each node
- Metadata tracking (hostname, port, uptime, etc.)
- Human-readable short IDs
- Extensible metadata system
Usage
Basic Usage
import { createNodeIdentity } from "@aurora/runtime-core";
// Create node identity with auto-generated UUID
const node = createNodeIdentity({
name: "aurora-node-1",
hostname: "localhost",
port: 3000,
});
console.log(node.getId()); // Full UUID
console.log(node.getShortId()); // aurora-node-1-a1b2c3d4
console.log(node.getMetadata()); // All node metadata
Update Metadata
// Update metadata after server starts
node.update({ port: 3001 });
Logging and Observability
// Use in logs
console.log(`[${node.getShortId()}] Server started`);
// Get uptime for health checks
console.log(`Uptime: ${node.getUptimeSeconds()}s`);
// Format for structured logging
console.log(node.toString());
// Output: a1b2c3d4-... name=aurora-node-1 host=localhost port=3000
Custom Node IDs
// Useful for testing or when node ID comes from environment
const node = createNodeIdentity({
id: process.env.NODE_ID || randomUUID(),
name: process.env.NODE_NAME,
});
API Reference
NodeIdentity
Constructor
new NodeIdentity(config?: Partial<NodeMetadata>)
Methods
getId(): string- Get the full UUIDgetShortId(): string- Get shortened, human-readable IDgetMetadata(): Readonly<NodeMetadata>- Get all metadata (immutable)update(updates: Partial<NodeMetadata>): void- Update metadatagetUptimeSeconds(): number- Get node uptime in secondstoString(): string- Format node info for logging
NodeMetadata
interface NodeMetadata {
id: string; // Unique node ID (UUID)
name?: string; // Human-readable node name
hostname?: string; // Hostname where node is running
port?: number; // HTTP server port
startedAt: Date; // When the node started
version?: string; // Aurora framework version
[key: string]: unknown; // Additional custom fields
}
Multi-Node Deployment
In a multi-node Aurora deployment, each node generates a unique identity on startup. This is used for:
- Logging: Distinguish log entries from different nodes
- Metrics: Tag metrics with node ID for per-node observability
- Debugging: Identify which node handled a request
- Health Checks: Track node uptime and status
Example multi-node setup:
// Node 1
const node1 = createNodeIdentity({
name: "aurora-node-1",
port: 3000,
});
// Node 2
const node2 = createNodeIdentity({
name: "aurora-node-2",
port: 3001,
});
// Both nodes process events from the same NATS JetStream
// with load-balanced consumer groups
License
MIT
Details
2025-12-27 10:44:37 +00:00
Assets (1)
Versions (3)
View all
npm
3
latest
3.1 KiB
runtime-core-0.3.3.tgz
3.1 KiB