@fjell/registry 4.4.51 → 4.4.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/API.md +0 -62
- package/GETTING_STARTED.md +0 -69
- package/build.js +0 -38
- package/docs/README.md +0 -74
- package/docs/TIMING_NODE_OPTIMIZATION.md +0 -207
- package/docs/TIMING_README.md +0 -170
- package/docs/docs.config.ts +0 -114
- package/docs/index.html +0 -26
- package/docs/package-lock.json +0 -5129
- package/docs/package.json +0 -34
- package/docs/public/404.html +0 -53
- package/docs/public/GETTING_STARTED.md +0 -69
- package/docs/public/README.md +0 -623
- package/docs/public/TIMING_NODE_OPTIMIZATION.md +0 -207
- package/docs/public/api.md +0 -62
- package/docs/public/client-api-overview.md +0 -137
- package/docs/public/configuration.md +0 -759
- package/docs/public/error-handling/README.md +0 -356
- package/docs/public/error-handling/network-errors.md +0 -485
- package/docs/public/examples/coordinates-example.ts +0 -253
- package/docs/public/examples/multi-level-keys.ts +0 -374
- package/docs/public/examples/registry-hub-coordinates-example.ts +0 -370
- package/docs/public/examples/registry-hub-types.ts +0 -437
- package/docs/public/examples/simple-example.ts +0 -250
- package/docs/public/examples-README.md +0 -241
- package/docs/public/fjell-icon.svg +0 -1
- package/docs/public/icon.png +0 -0
- package/docs/public/icon2.png +0 -0
- package/docs/public/memory-overhead.svg +0 -120
- package/docs/public/memory.md +0 -430
- package/docs/public/operations/README.md +0 -121
- package/docs/public/operations/all.md +0 -325
- package/docs/public/operations/create.md +0 -415
- package/docs/public/operations/get.md +0 -389
- package/docs/public/package.json +0 -63
- package/docs/public/pano.png +0 -0
- package/docs/public/pano2.png +0 -0
- package/docs/public/timing-range.svg +0 -176
- package/docs/public/timing.md +0 -483
- package/docs/timing-range.svg +0 -174
- package/docs/vitest.config.ts +0 -14
- package/examples/README.md +0 -241
- package/examples/coordinates-example.ts +0 -253
- package/examples/multi-level-keys.ts +0 -382
- package/examples/registry-hub-coordinates-example.ts +0 -370
- package/examples/registry-hub-types.ts +0 -437
- package/examples/registry-statistics-example.ts +0 -264
- package/examples/simple-example.ts +0 -250
- package/tsconfig.docs.json +0 -28
- package/vitest.config.ts +0 -22
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
# Node.js Optimization for Timing Tests
|
|
2
|
-
|
|
3
|
-
This document outlines Node.js runtime parameters that can be tuned to minimize interference and improve timing test accuracy.
|
|
4
|
-
|
|
5
|
-
## Quick Start: Optimized Timing Test
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
pnpm run test:timing:optimized
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
This runs timing tests with pre-configured optimal Node.js flags.
|
|
12
|
-
|
|
13
|
-
## Key Node.js Optimization Flags
|
|
14
|
-
|
|
15
|
-
### Memory Management
|
|
16
|
-
|
|
17
|
-
#### `--max-old-space-size=8192`
|
|
18
|
-
- **Purpose**: Increases maximum heap size to 8GB (default ~1.4GB)
|
|
19
|
-
- **Benefit**: Prevents garbage collection during test runs
|
|
20
|
-
- **Why 8GB**: Provides ample headroom for 100 rounds × multiple tree sizes
|
|
21
|
-
- **Alternative**: `--max-old-space-size=4096` for systems with less RAM
|
|
22
|
-
|
|
23
|
-
#### `--max-semi-space-size=1024`
|
|
24
|
-
- **Purpose**: Increases semi-space size to 1GB (default varies)
|
|
25
|
-
- **Benefit**: Reduces minor GC frequency during object allocation
|
|
26
|
-
- **Impact**: Each semi-space can hold more objects before collection
|
|
27
|
-
|
|
28
|
-
### Garbage Collection Control
|
|
29
|
-
|
|
30
|
-
#### `--expose-gc`
|
|
31
|
-
- **Purpose**: Exposes `global.gc()` function for manual garbage collection
|
|
32
|
-
- **Benefit**: Allows forced GC between test rounds for consistent baselines
|
|
33
|
-
- **Usage**: Can trigger GC at specific points to isolate timing measurements
|
|
34
|
-
|
|
35
|
-
#### `--gc-interval=1000000`
|
|
36
|
-
- **Purpose**: Reduces GC frequency (higher number = less frequent)
|
|
37
|
-
- **Benefit**: Minimizes GC interruptions during timing measurements
|
|
38
|
-
- **Trade-off**: Uses more memory but provides consistent timing
|
|
39
|
-
|
|
40
|
-
### Execution Predictability
|
|
41
|
-
|
|
42
|
-
#### `--predictable`
|
|
43
|
-
- **Purpose**: Makes execution more deterministic
|
|
44
|
-
- **Benefit**: Reduces timing variance from non-deterministic optimizations
|
|
45
|
-
- **Impact**: Slightly slower but more consistent measurements
|
|
46
|
-
|
|
47
|
-
#### `--no-compilation-cache`
|
|
48
|
-
- **Purpose**: Disables V8 compilation cache
|
|
49
|
-
- **Benefit**: Ensures consistent JIT compilation behavior across runs
|
|
50
|
-
- **Use Case**: When testing cold start performance or eliminating cache effects
|
|
51
|
-
|
|
52
|
-
### JIT Compilation Control
|
|
53
|
-
|
|
54
|
-
#### `--optimize-for-size`
|
|
55
|
-
- **Purpose**: Optimizes for code size rather than speed
|
|
56
|
-
- **Benefit**: More predictable compilation behavior
|
|
57
|
-
- **Alternative**: `--max-opt` for maximum optimization (less predictable)
|
|
58
|
-
|
|
59
|
-
#### `--no-opt`
|
|
60
|
-
- **Purpose**: Disables JIT compilation entirely
|
|
61
|
-
- **Benefit**: Eliminates JIT timing variance (but much slower execution)
|
|
62
|
-
- **Use Case**: Testing interpreter-only performance
|
|
63
|
-
|
|
64
|
-
## Complete Optimization Command
|
|
65
|
-
|
|
66
|
-
For maximum timing accuracy, use all optimization flags:
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
# Use NODE_OPTIONS for compatibility with modern Node.js
|
|
70
|
-
NODE_OPTIONS="--max-old-space-size=8192 --max-semi-space-size=1024" \
|
|
71
|
-
vitest run tests/timing.test.ts
|
|
72
|
-
|
|
73
|
-
# Or use direct node invocation (requires vitest executable)
|
|
74
|
-
node --max-old-space-size=8192 --max-semi-space-size=1024 \
|
|
75
|
-
./node_modules/vitest/vitest.mjs run tests/timing.test.ts
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## System-Specific Adjustments
|
|
79
|
-
|
|
80
|
-
### Low-Memory Systems (< 8GB RAM)
|
|
81
|
-
```bash
|
|
82
|
-
NODE_OPTIONS="--max-old-space-size=2048 --max-semi-space-size=256" \
|
|
83
|
-
vitest run tests/timing.test.ts
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### High-Memory Systems (> 16GB RAM)
|
|
87
|
-
```bash
|
|
88
|
-
NODE_OPTIONS="--max-old-space-size=16384 --max-semi-space-size=2048" \
|
|
89
|
-
vitest run tests/timing.test.ts
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Docker/Container Environments
|
|
93
|
-
```bash
|
|
94
|
-
NODE_OPTIONS="--max-old-space-size=4096 --max-semi-space-size=512" \
|
|
95
|
-
vitest run tests/timing.test.ts
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## Environment Variables
|
|
99
|
-
|
|
100
|
-
### Additional V8 Options
|
|
101
|
-
```bash
|
|
102
|
-
export NODE_OPTIONS="--max-old-space-size=8192 --max-semi-space-size=1024"
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Memory Monitoring
|
|
106
|
-
```bash
|
|
107
|
-
export NODE_ENV=production # Disable development overhead
|
|
108
|
-
export UV_THREADPOOL_SIZE=8 # Increase thread pool if needed
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
## Monitoring Memory During Tests
|
|
112
|
-
|
|
113
|
-
Add memory monitoring to timing tests:
|
|
114
|
-
|
|
115
|
-
```typescript
|
|
116
|
-
// Add to timing test setup
|
|
117
|
-
if (global.gc) {
|
|
118
|
-
console.log('Memory before tests:', process.memoryUsage());
|
|
119
|
-
global.gc();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Add between test rounds
|
|
123
|
-
if (global.gc && round % 20 === 0) {
|
|
124
|
-
global.gc();
|
|
125
|
-
console.log(`Memory after round ${round}:`, process.memoryUsage());
|
|
126
|
-
}
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
## Platform-Specific Considerations
|
|
130
|
-
|
|
131
|
-
### macOS
|
|
132
|
-
- Default memory limits are generous
|
|
133
|
-
- Use `--max-old-space-size=8192` safely
|
|
134
|
-
- Activity Monitor shows Node.js memory usage
|
|
135
|
-
|
|
136
|
-
### Linux
|
|
137
|
-
- Check `ulimit -v` for virtual memory limits
|
|
138
|
-
- May need `sudo sysctl vm.max_map_count=262144` for large heaps
|
|
139
|
-
- Use `htop` or `ps` to monitor memory
|
|
140
|
-
|
|
141
|
-
### Windows
|
|
142
|
-
- WSL may have memory constraints
|
|
143
|
-
- PowerShell: `Get-Process node | Select-Object WorkingSet64`
|
|
144
|
-
- Task Manager shows detailed memory breakdown
|
|
145
|
-
|
|
146
|
-
### CI/CD Environments
|
|
147
|
-
- GitHub Actions: 7GB RAM limit, use `--max-old-space-size=4096`
|
|
148
|
-
- GitLab CI: Variable memory, check runner specs
|
|
149
|
-
- Docker: Set container memory limits appropriately
|
|
150
|
-
|
|
151
|
-
## Performance Analysis Tools
|
|
152
|
-
|
|
153
|
-
### V8 Profiling
|
|
154
|
-
```bash
|
|
155
|
-
node --prof --log-timer-events ./timing-test.js
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### Heap Snapshots
|
|
159
|
-
```bash
|
|
160
|
-
node --inspect --heap-prof ./timing-test.js
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
### GC Logging
|
|
164
|
-
```bash
|
|
165
|
-
node --trace-gc --trace-gc-verbose ./timing-test.js
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
## Validation
|
|
169
|
-
|
|
170
|
-
Test that optimizations are working:
|
|
171
|
-
|
|
172
|
-
```bash
|
|
173
|
-
# Run normal timing tests
|
|
174
|
-
npm run test:timing
|
|
175
|
-
|
|
176
|
-
# Run optimized timing tests
|
|
177
|
-
npm run test:timing:optimized
|
|
178
|
-
|
|
179
|
-
# Compare results - optimized should show:
|
|
180
|
-
# 1. Lower timing variance (smaller standard deviations)
|
|
181
|
-
# 2. More consistent Bollinger bands
|
|
182
|
-
# 3. Fewer outlier measurements
|
|
183
|
-
# 4. Reduced memory-related timing spikes
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
## Recommended Configuration
|
|
187
|
-
|
|
188
|
-
For most use cases, the optimized configuration provides the best balance:
|
|
189
|
-
|
|
190
|
-
```json
|
|
191
|
-
{
|
|
192
|
-
"scripts": {
|
|
193
|
-
"test:timing:optimized": "NODE_OPTIONS=\"--max-old-space-size=8192 --max-semi-space-size=1024\" vitest run tests/timing.test.ts"
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
This configuration:
|
|
199
|
-
- ✅ Eliminates most GC interference
|
|
200
|
-
- ✅ Provides consistent execution
|
|
201
|
-
- ✅ Works on most development machines
|
|
202
|
-
- ✅ Maintains reasonable test execution time
|
|
203
|
-
- ✅ Produces reliable performance metrics
|
|
204
|
-
|
|
205
|
-
---
|
|
206
|
-
|
|
207
|
-
*For production timing analysis, always use optimized Node.js flags to ensure accurate performance measurements.*
|
package/docs/public/api.md
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# API Reference
|
|
2
|
-
|
|
3
|
-
Complete Registry API documentation and method reference.
|
|
4
|
-
|
|
5
|
-
## Core Registry Interface
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
interface Registry {
|
|
9
|
-
readonly type: string; // Mandatory type identifier
|
|
10
|
-
createInstance: <...>(...) => Instance<...>;
|
|
11
|
-
get: (...) => Instance | null;
|
|
12
|
-
getCoordinates: () => Coordinate[]; // Discover all registered coordinates
|
|
13
|
-
instanceTree: InstanceTree;
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Primary Methods
|
|
18
|
-
|
|
19
|
-
### `createRegistry(type: string): Registry`
|
|
20
|
-
Creates a new registry with the specified type identifier.
|
|
21
|
-
|
|
22
|
-
### `registry.createInstance(kta, scopes, factory)`
|
|
23
|
-
Registers a new service instance with the given key type array and scopes.
|
|
24
|
-
|
|
25
|
-
### `registry.get(kta, options)`
|
|
26
|
-
Retrieves a service instance by key type array and scope options.
|
|
27
|
-
|
|
28
|
-
### `registry.getCoordinates(): Coordinate[]`
|
|
29
|
-
Returns all registered coordinates for service discovery and introspection.
|
|
30
|
-
|
|
31
|
-
## RegistryHub Interface
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
interface RegistryHub {
|
|
35
|
-
registerRegistry: (registry: Registry) => void;
|
|
36
|
-
get: (registryType: string, kta: string[], options?: GetOptions) => Instance | null;
|
|
37
|
-
getRegistries: () => Registry[];
|
|
38
|
-
getAllCoordinates: () => Array<{coordinate: Coordinate, registryType: string}>;
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Coordinate System
|
|
43
|
-
|
|
44
|
-
```typescript
|
|
45
|
-
interface Coordinate {
|
|
46
|
-
kta: string[]; // Key Type Array - hierarchical identifiers
|
|
47
|
-
scopes: string[]; // Context qualifiers
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Complete Documentation
|
|
52
|
-
|
|
53
|
-
For comprehensive API documentation with detailed examples, implementation patterns, and advanced usage scenarios, see the **Foundation** section which contains the complete Registry documentation including:
|
|
54
|
-
|
|
55
|
-
- Interface definitions and type signatures
|
|
56
|
-
- Detailed method documentation with examples
|
|
57
|
-
- Registry and RegistryHub patterns
|
|
58
|
-
- Coordinate system explanation
|
|
59
|
-
- Service discovery and introspection
|
|
60
|
-
- Error handling and best practices
|
|
61
|
-
|
|
62
|
-
The Foundation section serves as the authoritative API reference with full context and examples.
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
# Client API Documentation
|
|
2
|
-
|
|
3
|
-
Welcome to the comprehensive Client API documentation for the Fjell ecosystem. This section provides complete guidance for building resilient, production-ready applications with advanced error handling and retry logic.
|
|
4
|
-
|
|
5
|
-
## What's New
|
|
6
|
-
|
|
7
|
-
The Client API now includes enterprise-grade error handling and resilience features:
|
|
8
|
-
|
|
9
|
-
- **🔄 Automatic Retry Logic** - Exponential backoff with jitter for transient failures
|
|
10
|
-
- **🎯 Custom Error Types** - 10+ specific error classes for different scenarios
|
|
11
|
-
- **🛡️ Production Resilience** - Circuit breakers, graceful degradation, monitoring integration
|
|
12
|
-
- **⚙️ Flexible Configuration** - Environment-aware settings for dev, staging, and production
|
|
13
|
-
- **📊 Comprehensive Monitoring** - Error tracking, metrics, and alerting integration
|
|
14
|
-
|
|
15
|
-
## Documentation Sections
|
|
16
|
-
|
|
17
|
-
### Operations
|
|
18
|
-
Complete guides for all API operations with examples, error handling, and best practices:
|
|
19
|
-
|
|
20
|
-
- **[Operations Overview](./operations/README.md)** - Complete guide to all available operations
|
|
21
|
-
- **[All Operation](./operations/all.md)** - Retrieve multiple items with queries, pagination, and filtering
|
|
22
|
-
- **[Create Operation](./operations/create.md)** - Create new items with validation and batch operations
|
|
23
|
-
- **[Get Operation](./operations/get.md)** - Retrieve single items by key with caching strategies
|
|
24
|
-
|
|
25
|
-
### Error Handling & Resilience
|
|
26
|
-
Advanced error handling for production environments:
|
|
27
|
-
|
|
28
|
-
- **[Error Handling Overview](./error-handling/README.md)** - Comprehensive error handling system
|
|
29
|
-
- **[Network Errors](./error-handling/network-errors.md)** - Handle connection failures and timeouts
|
|
30
|
-
|
|
31
|
-
### Configuration
|
|
32
|
-
Complete setup and configuration guide:
|
|
33
|
-
|
|
34
|
-
- **[Configuration Guide](./configuration.md)** - API setup, authentication, and environment configuration
|
|
35
|
-
|
|
36
|
-
## Quick Start
|
|
37
|
-
|
|
38
|
-
### Basic Setup
|
|
39
|
-
|
|
40
|
-
```typescript
|
|
41
|
-
import { createPItemApi } from '@fjell/client-api';
|
|
42
|
-
|
|
43
|
-
const userApi = createPItemApi<User, 'user'>('user', ['users'], {
|
|
44
|
-
baseUrl: 'https://api.example.com',
|
|
45
|
-
enableErrorHandling: true,
|
|
46
|
-
retryConfig: {
|
|
47
|
-
maxRetries: 3,
|
|
48
|
-
initialDelayMs: 1000,
|
|
49
|
-
maxDelayMs: 30000,
|
|
50
|
-
backoffMultiplier: 2,
|
|
51
|
-
enableJitter: true
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### With Error Handling
|
|
57
|
-
|
|
58
|
-
```typescript
|
|
59
|
-
try {
|
|
60
|
-
const user = await userApi.create({
|
|
61
|
-
name: 'John Doe',
|
|
62
|
-
email: 'john@example.com'
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
console.log('User created:', user.id);
|
|
66
|
-
} catch (error) {
|
|
67
|
-
if (error.code === 'VALIDATION_ERROR') {
|
|
68
|
-
// Handle validation errors
|
|
69
|
-
error.validationErrors.forEach(err => {
|
|
70
|
-
console.log(`${err.field}: ${err.message}`);
|
|
71
|
-
});
|
|
72
|
-
} else if (error.code === 'NETWORK_ERROR') {
|
|
73
|
-
// Network errors are automatically retried
|
|
74
|
-
console.log('Network issue resolved or exhausted retries');
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Key Features
|
|
80
|
-
|
|
81
|
-
### Error Types Handled
|
|
82
|
-
|
|
83
|
-
| Error Type | Code | Retryable | Description |
|
|
84
|
-
|------------|------|-----------|-------------|
|
|
85
|
-
| **NetworkError** | `NETWORK_ERROR` | ✅ | Connection failures, DNS issues |
|
|
86
|
-
| **TimeoutError** | `TIMEOUT_ERROR` | ✅ | Request timeouts |
|
|
87
|
-
| **ServerError** | `SERVER_ERROR` | ✅ | 5xx HTTP status codes |
|
|
88
|
-
| **RateLimitError** | `RATE_LIMIT_ERROR` | ✅ | 429 Too Many Requests |
|
|
89
|
-
| **AuthenticationError** | `AUTHENTICATION_ERROR` | ❌ | 401 Unauthorized |
|
|
90
|
-
| **ValidationError** | `VALIDATION_ERROR` | ❌ | 400 Bad Request |
|
|
91
|
-
| **NotFoundError** | `NOT_FOUND_ERROR` | ❌ | 404 Not Found |
|
|
92
|
-
|
|
93
|
-
### Production Configuration
|
|
94
|
-
|
|
95
|
-
```typescript
|
|
96
|
-
const productionConfig = {
|
|
97
|
-
baseUrl: 'https://api.example.com',
|
|
98
|
-
retryConfig: {
|
|
99
|
-
maxRetries: 5,
|
|
100
|
-
initialDelayMs: 1000,
|
|
101
|
-
maxDelayMs: 60000,
|
|
102
|
-
backoffMultiplier: 1.5,
|
|
103
|
-
enableJitter: true
|
|
104
|
-
},
|
|
105
|
-
errorHandler: (error, context) => {
|
|
106
|
-
// Send to monitoring service
|
|
107
|
-
monitoring.recordError(error, context);
|
|
108
|
-
|
|
109
|
-
// Business-specific error handling
|
|
110
|
-
if (error.code === 'PAYMENT_FAILED') {
|
|
111
|
-
notificationService.sendPaymentFailure(context.customerId);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
## Examples
|
|
118
|
-
|
|
119
|
-
See the [Examples](../examples-README.md) section for complete usage scenarios including:
|
|
120
|
-
|
|
121
|
-
- Simple API operations with error handling
|
|
122
|
-
- Enterprise e-commerce platform patterns
|
|
123
|
-
- Comprehensive error handling demonstrations
|
|
124
|
-
- Production configuration examples
|
|
125
|
-
|
|
126
|
-
## Support
|
|
127
|
-
|
|
128
|
-
For additional help:
|
|
129
|
-
|
|
130
|
-
- Review the detailed operation guides in the Operations section
|
|
131
|
-
- Check the Error Handling section for resilience patterns
|
|
132
|
-
- Explore the Configuration guide for setup options
|
|
133
|
-
- See the Examples for complete working code
|
|
134
|
-
|
|
135
|
-
---
|
|
136
|
-
|
|
137
|
-
*Built with comprehensive error handling and production resilience in mind.*
|