tricache 1.0.1 → 2.0.0
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/README.md +89 -93
- package/dashboards/tricache-alerts.yaml +80 -4
- package/dashboards/tricache-grafana.json +54 -1
- package/dashboards/tricache-inventory.rules.yml +21 -0
- package/dist/cache-service-BV5T8-20.d.cts +1064 -0
- package/dist/cache-service-UZXOQGEY.js +14 -0
- package/dist/{cache-service-CREOp7MM.d.ts → cache-service-tpyrXvlH.d.ts} +157 -24
- package/dist/{chunk-UBWLPKTI.js → chunk-EJXG7WO6.js} +152 -32
- package/dist/{chunk-IITRFWHY.js → chunk-EUKB7RKP.js} +21 -4
- package/dist/{chunk-7RV5ZVBB.js → chunk-JNSLMK4Q.js} +111 -29
- package/dist/{chunk-2AJKEQMZ.js → chunk-KV7KISK2.js} +54 -5
- package/dist/{chunk-JYQFQJNJ.js → chunk-MB3DMVWN.js} +3424 -1022
- package/dist/chunk-RBJRTGFK.js +94 -0
- package/dist/chunk-S5N65I45.js +17 -0
- package/dist/cli.cjs +3694 -1070
- package/dist/cli.d.cts +12 -0
- package/dist/cli.js +210 -14
- package/dist/dashboard/index.cjs +111 -29
- package/dist/dashboard/index.d.cts +185 -0
- package/dist/dashboard/index.d.ts +5 -3
- package/dist/dashboard/index.js +1 -1
- package/dist/drizzle/index.cjs +3578 -1068
- package/dist/drizzle/index.d.cts +46 -0
- package/dist/drizzle/index.d.ts +2 -2
- package/dist/drizzle/index.js +6 -2
- package/dist/edge/index.cjs +368 -162
- package/dist/edge/index.d.cts +134 -0
- package/dist/edge/index.d.ts +11 -4
- package/dist/edge/index.js +314 -155
- package/dist/hono/index.cjs +3614 -1087
- package/dist/hono/index.d.cts +93 -0
- package/dist/hono/index.d.ts +7 -5
- package/dist/hono/index.js +16 -9
- package/dist/hono-CMv2VdQ6.d.cts +404 -0
- package/dist/{hono-DSV2ve66.d.ts → hono-Dvq04kX9.d.ts} +33 -7
- package/dist/http/index.cjs +3712 -1124
- package/dist/http/index.d.cts +103 -0
- package/dist/http/index.d.ts +13 -5
- package/dist/http/index.js +92 -43
- package/dist/index.cjs +4067 -1252
- package/dist/index.d.cts +1071 -0
- package/dist/index.d.ts +123 -27
- package/dist/index.js +878 -21
- package/dist/{murmur3-CMGw9PbV.d.ts → murmur3-DF8BFRnu.d.cts} +1 -0
- package/dist/murmur3-DF8BFRnu.d.ts +99 -0
- package/dist/nestjs/index.cjs +3635 -1112
- package/dist/nestjs/index.d.cts +299 -0
- package/dist/nestjs/index.d.ts +120 -33
- package/dist/nestjs/index.js +132 -43
- package/dist/next/index.cjs +3704 -1175
- package/dist/next/index.d.cts +238 -0
- package/dist/next/index.d.ts +39 -11
- package/dist/next/index.js +202 -102
- package/dist/prisma/index.cjs +29 -18
- package/dist/prisma/index.d.cts +62 -0
- package/dist/prisma/index.d.ts +2 -2
- package/dist/prisma/index.js +17 -18
- package/dist/serialize-worker.cjs +162 -39
- package/dist/serialize-worker.d.cts +2 -0
- package/dist/serialize-worker.js +9 -7
- package/dist/{types-Dyip5wAl.d.ts → types-F8vRWMrE.d.cts} +186 -54
- package/dist/types-F8vRWMrE.d.ts +1636 -0
- package/dist/{utils-CEsU_Z0s.d.ts → utils-Bvzn-rKS.d.cts} +3 -1
- package/dist/utils-Bvzn-rKS.d.ts +29 -0
- package/package.json +116 -37
- package/src/adapters/auto-pipeliner.ts +150 -26
- package/src/adapters/node-redis.ts +106 -27
- package/src/cache-service.ts +2215 -793
- package/src/cli.ts +25 -14
- package/src/codec.ts +3 -3
- package/src/compression.ts +39 -16
- package/src/cross-region.ts +22 -4
- package/src/dashboard/handler.ts +26 -6
- package/src/dashboard/html.ts +35 -10
- package/src/dashboard/index.ts +35 -13
- package/src/dashboard/types.ts +3 -1
- package/src/disk-tier.ts +448 -102
- package/src/drizzle/index.ts +2 -1
- package/src/edge/adapters/cloudflare-do.ts +25 -10
- package/src/edge/adapters/cloudflare-kv.ts +12 -9
- package/src/edge/adapters/upstash.ts +27 -11
- package/src/edge/cache.ts +200 -110
- package/src/edge/hono.ts +23 -6
- package/src/edge/types.ts +17 -5
- package/src/encryption.ts +50 -18
- package/src/env.d.ts +1 -1
- package/src/errors.ts +12 -0
- package/src/hono/index.ts +19 -9
- package/src/http/express.ts +62 -17
- package/src/http/fastify.ts +35 -21
- package/src/http/utils.ts +60 -20
- package/src/index.ts +6 -0
- package/src/ipc-telemetry.ts +35 -9
- package/src/latency-watchdog.ts +5 -1
- package/src/nestjs/decorators.ts +11 -6
- package/src/nestjs/index.ts +2 -0
- package/src/nestjs/keyv-adapter.ts +68 -0
- package/src/nestjs/tricache.module.ts +15 -12
- package/src/nestjs/tricache.store.ts +69 -26
- package/src/nestjs/types.ts +30 -16
- package/src/next/cache-handler.ts +151 -53
- package/src/next/index.ts +1 -0
- package/src/next/types.ts +25 -0
- package/src/origin-capacity.ts +134 -0
- package/src/prisma/index.ts +17 -24
- package/src/remote-snapshot.ts +37 -27
- package/src/serialize-worker.ts +8 -5
- package/src/sigv4-snapshot-adapter.ts +37 -27
- package/src/smart-memory-cache.ts +121 -44
- package/src/types.ts +117 -37
- package/src/utils/cgroup.ts +12 -0
- package/src/utils/config-comparison.ts +29 -0
- package/src/utils/deadline.ts +14 -0
- package/src/utils/diagnostics.ts +27 -0
- package/src/utils/lz4-size.ts +74 -0
- package/src/utils/namespace-key.ts +48 -0
- package/src/utils/query-key.ts +13 -0
- package/src/utils/redis-slot.ts +13 -0
- package/src/utils/snapshot-transfer.ts +83 -0
- package/src/utils/work-limits.ts +73 -0
- package/src/utils/write-revision.ts +4 -0
- package/src/wasm/bloom-filter-wasm.ts +25 -5
- package/src/worker-pool.ts +44 -15
- package/src/wtiny-lfu.ts +82 -20
- package/dist/cache-service-MG7PN6MX.js +0 -12
- package/dist/chunk-3I5L7K6I.js +0 -704
- package/dist/chunk-BQRURGGD.js +0 -60
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import http, { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { C as CacheService } from '../cache-service-BV5T8-20.cjs';
|
|
3
|
+
import '../types-F8vRWMrE.cjs';
|
|
4
|
+
import 'crypto';
|
|
5
|
+
|
|
6
|
+
interface DashboardPeerInstance {
|
|
7
|
+
name: string;
|
|
8
|
+
url: string;
|
|
9
|
+
}
|
|
10
|
+
interface DashboardActionEvent {
|
|
11
|
+
action: 'clear' | 'invalidate-tag';
|
|
12
|
+
target?: string;
|
|
13
|
+
user?: string;
|
|
14
|
+
ip?: string;
|
|
15
|
+
timestamp: number;
|
|
16
|
+
success: boolean;
|
|
17
|
+
error?: string;
|
|
18
|
+
}
|
|
19
|
+
interface DashboardOptions {
|
|
20
|
+
/**
|
|
21
|
+
* TriCache instance to monitor and manage.
|
|
22
|
+
*/
|
|
23
|
+
cache: CacheService;
|
|
24
|
+
/**
|
|
25
|
+
* Base mounting path for the dashboard (e.g. '/cache/dashboard' or '/admin/cache').
|
|
26
|
+
* Used for generating relative links and API request paths.
|
|
27
|
+
* @default ''
|
|
28
|
+
*/
|
|
29
|
+
basePath?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Custom title displayed in the browser tab and dashboard header.
|
|
32
|
+
* @default 'TriCache Observability'
|
|
33
|
+
*/
|
|
34
|
+
title?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Identifier for the local container/pod/process.
|
|
37
|
+
* Defaults to process.env.POD_NAME, process.env.HOSTNAME, or os.hostname().
|
|
38
|
+
*/
|
|
39
|
+
instanceId?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Optional list of sibling peer instance URLs for pod switching in multi-pod clusters.
|
|
42
|
+
*/
|
|
43
|
+
peerInstances?: DashboardPeerInstance[];
|
|
44
|
+
/**
|
|
45
|
+
* HTTP Basic Authentication credentials.
|
|
46
|
+
* Evaluated using timing-safe comparison (crypto.timingSafeEqual with SHA-256).
|
|
47
|
+
*/
|
|
48
|
+
auth?: {
|
|
49
|
+
username: string;
|
|
50
|
+
password: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Bearer token or URL token query parameter ('?token=...') for API authentication.
|
|
54
|
+
* Evaluated using timing-safe comparison.
|
|
55
|
+
*/
|
|
56
|
+
authSecret?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Enforces read-only mode: disables and blocks all mutating operations
|
|
59
|
+
* (e.g. invalidate tag, clear cache tier). Mutating endpoints return 403 Forbidden.
|
|
60
|
+
* @default true
|
|
61
|
+
*/
|
|
62
|
+
readOnly?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Server-Sent Events (SSE) metric stream push interval in milliseconds.
|
|
65
|
+
* @default 2000
|
|
66
|
+
*/
|
|
67
|
+
streamIntervalMs?: number;
|
|
68
|
+
/** Maximum administrative request body size. Default: 64 KiB. */
|
|
69
|
+
maxRequestBytes?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Enterprise audit logging hook invoked when an administrative action is attempted.
|
|
72
|
+
* Allows piping security/audit events to Datadog, CloudWatch, Splunk, etc.
|
|
73
|
+
*/
|
|
74
|
+
onAction?: (event: DashboardActionEvent) => void;
|
|
75
|
+
}
|
|
76
|
+
interface StandaloneDashboardOptions extends DashboardOptions {
|
|
77
|
+
/**
|
|
78
|
+
* Port to listen on.
|
|
79
|
+
* @default 9090
|
|
80
|
+
*/
|
|
81
|
+
port?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Host / IP interface to bind. Defaults to '127.0.0.1' for security.
|
|
84
|
+
* Use '0.0.0.0' only inside private VPCs or behind authenticated reverse proxies.
|
|
85
|
+
* @default '127.0.0.1'
|
|
86
|
+
*/
|
|
87
|
+
host?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Timing-safe string comparison routine using SHA-256 digests to neutralize
|
|
92
|
+
* both length-leakage side-channels and buffer-length mismatch exceptions.
|
|
93
|
+
*/
|
|
94
|
+
declare function safeCompare(a: string, b: string): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Resolve local instance/pod identifier from options or environment.
|
|
97
|
+
*/
|
|
98
|
+
declare function resolveInstanceId(custom?: string): string;
|
|
99
|
+
/**
|
|
100
|
+
* Build the JSON snapshot payload for /api/metrics and SSE stream events.
|
|
101
|
+
*/
|
|
102
|
+
declare function buildMetricsPayload(options: DashboardOptions): Record<string, unknown>;
|
|
103
|
+
/**
|
|
104
|
+
* Framework-agnostic Web Standards request handler for the TriCache dashboard.
|
|
105
|
+
* Accepts a Web Standard Request and returns a Web Standard Response.
|
|
106
|
+
*/
|
|
107
|
+
declare function handleDashboardRequest(req: Request, options: DashboardOptions): Promise<Response>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Embedded Single-Page Observability Dashboard for TriCache.
|
|
111
|
+
*
|
|
112
|
+
* Design features:
|
|
113
|
+
* - 100% self-contained & air-gapped (zero external CDN or font dependencies)
|
|
114
|
+
* - Modern dark glassmorphic UI with high contrast and smooth micro-animations
|
|
115
|
+
* - Server-Sent Events (SSE) live streaming with auto-reconnect and polling fallback
|
|
116
|
+
* - Pod vs. Fleet cluster awareness indicators
|
|
117
|
+
* - Immutable HTML pre-compressed with Gzip at module initialization
|
|
118
|
+
*/
|
|
119
|
+
declare const DASHBOARD_HTML: string;
|
|
120
|
+
/**
|
|
121
|
+
* Pre-compressed Gzip binary representation of the immutable dashboard HTML.
|
|
122
|
+
* Served directly with Content-Encoding: gzip to minimize latency and CPU overhead.
|
|
123
|
+
*/
|
|
124
|
+
declare const DASHBOARD_GZIP_BUFFER: Buffer;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Connect/Express/Fastify middleware adapter for the TriCache observability dashboard.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* import { tricacheDashboard } from 'tricache/dashboard';
|
|
132
|
+
*
|
|
133
|
+
* app.use('/admin/cache', tricacheDashboard({
|
|
134
|
+
* cache,
|
|
135
|
+
* auth: { username: 'admin', password: process.env.DASHBOARD_PASSWORD },
|
|
136
|
+
* readOnly: process.env.NODE_ENV === 'production',
|
|
137
|
+
* }));
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
declare function tricacheDashboard(options: DashboardOptions): (req: IncomingMessage, res: ServerResponse, next?: (err?: unknown) => void) => Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Next.js App Router route handlers for the TriCache dashboard.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* // app/admin/cache/[...slug]/route.ts
|
|
147
|
+
* import { createNextDashboardHandlers } from 'tricache/dashboard';
|
|
148
|
+
* import { cache } from '@/lib/cache';
|
|
149
|
+
*
|
|
150
|
+
* export const { GET, POST } = createNextDashboardHandlers({
|
|
151
|
+
* cache,
|
|
152
|
+
* basePath: '/admin/cache',
|
|
153
|
+
* readOnly: true,
|
|
154
|
+
* });
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
declare function createNextDashboardHandlers(options: DashboardOptions): {
|
|
158
|
+
GET: (req: Request) => Promise<Response>;
|
|
159
|
+
POST: (req: Request) => Promise<Response>;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Starts a standalone, dedicated HTTP management server for the TriCache dashboard.
|
|
163
|
+
* Ideal for microservices, background workers, and Kubernetes pods via `kubectl port-forward`.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* import { startDashboardServer } from 'tricache/dashboard';
|
|
168
|
+
*
|
|
169
|
+
* const mgmt = await startDashboardServer({
|
|
170
|
+
* cache,
|
|
171
|
+
* port: 9090,
|
|
172
|
+
* host: '127.0.0.1',
|
|
173
|
+
* authSecret: process.env.MANAGEMENT_SECRET,
|
|
174
|
+
* });
|
|
175
|
+
* console.log(`Observability dashboard running at http://localhost:${mgmt.port}`);
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
declare function startDashboardServer(options: StandaloneDashboardOptions): Promise<{
|
|
179
|
+
server: http.Server;
|
|
180
|
+
port: number;
|
|
181
|
+
host: string;
|
|
182
|
+
close: () => Promise<void>;
|
|
183
|
+
}>;
|
|
184
|
+
|
|
185
|
+
export { DASHBOARD_GZIP_BUFFER, DASHBOARD_HTML, type DashboardActionEvent, type DashboardOptions, type DashboardPeerInstance, type StandaloneDashboardOptions, buildMetricsPayload, createNextDashboardHandlers, handleDashboardRequest, resolveInstanceId, safeCompare, startDashboardServer, tricacheDashboard };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import http, { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import { C as CacheService } from '../cache-service-
|
|
3
|
-
import '../types-
|
|
2
|
+
import { C as CacheService } from '../cache-service-tpyrXvlH.js';
|
|
3
|
+
import '../types-F8vRWMrE.js';
|
|
4
4
|
import 'crypto';
|
|
5
5
|
|
|
6
6
|
interface DashboardPeerInstance {
|
|
@@ -57,7 +57,7 @@ interface DashboardOptions {
|
|
|
57
57
|
/**
|
|
58
58
|
* Enforces read-only mode: disables and blocks all mutating operations
|
|
59
59
|
* (e.g. invalidate tag, clear cache tier). Mutating endpoints return 403 Forbidden.
|
|
60
|
-
* @default
|
|
60
|
+
* @default true
|
|
61
61
|
*/
|
|
62
62
|
readOnly?: boolean;
|
|
63
63
|
/**
|
|
@@ -65,6 +65,8 @@ interface DashboardOptions {
|
|
|
65
65
|
* @default 2000
|
|
66
66
|
*/
|
|
67
67
|
streamIntervalMs?: number;
|
|
68
|
+
/** Maximum administrative request body size. Default: 64 KiB. */
|
|
69
|
+
maxRequestBytes?: number;
|
|
68
70
|
/**
|
|
69
71
|
* Enterprise audit logging hook invoked when an administrative action is attempted.
|
|
70
72
|
* Allows piping security/audit events to Datadog, CloudWatch, Splunk, etc.
|