@compforge/harness-toolbox 0.1.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 +47 -0
- package/dist/chunk-0rs1aacd.js +127 -0
- package/dist/chunk-1at7zs0z.js +104 -0
- package/dist/chunk-1vfwvgkj.js +104 -0
- package/dist/chunk-205a4vma.js +85 -0
- package/dist/chunk-3dt25p98.js +59 -0
- package/dist/chunk-6fnhzhdb.js +103 -0
- package/dist/chunk-8nm9f0hh.js +92 -0
- package/dist/chunk-ajhdd4hp.js +267 -0
- package/dist/chunk-c6z919qb.js +98 -0
- package/dist/chunk-djk4kmxb.js +0 -0
- package/dist/chunk-hqx7j9xe.js +14 -0
- package/dist/chunk-hv2kx47y.js +92 -0
- package/dist/chunk-j46x7j7c.js +73 -0
- package/dist/chunk-jr9y0ghr.js +157 -0
- package/dist/chunk-mkhyty75.js +166 -0
- package/dist/chunk-mp88s7r7.js +12 -0
- package/dist/chunk-pfar9cm3.js +0 -0
- package/dist/chunk-qq77x9ek.js +34 -0
- package/dist/chunk-s06hs7a8.js +79 -0
- package/dist/chunk-s1sjyem7.js +41 -0
- package/dist/chunk-v3hxvnrc.js +47 -0
- package/dist/chunk-w3a4p6jm.js +124 -0
- package/dist/chunk-xy4g56g4.js +50 -0
- package/dist/chunk-ztenxgjv.js +27 -0
- package/dist/client-manager.d.ts +14 -0
- package/dist/client-manager.js +6 -0
- package/dist/client.d.ts +5 -0
- package/dist/client.js +0 -0
- package/dist/concurrency.d.ts +7 -0
- package/dist/concurrency.js +6 -0
- package/dist/datasource.d.ts +26 -0
- package/dist/datasource.js +10 -0
- package/dist/kubernetes/client-node-pod-log.d.ts +31 -0
- package/dist/kubernetes/client-node-pod-log.js +425 -0
- package/dist/kubernetes/client.d.ts +17 -0
- package/dist/kubernetes/client.js +92 -0
- package/dist/kubernetes/endpoint.d.ts +4 -0
- package/dist/kubernetes/endpoint.js +0 -0
- package/dist/kubernetes/executor.d.ts +45 -0
- package/dist/kubernetes/executor.js +13 -0
- package/dist/kubernetes/log-capture-file.d.ts +12 -0
- package/dist/kubernetes/log-capture-file.js +6 -0
- package/dist/kubernetes/log-capture-plan.d.ts +29 -0
- package/dist/kubernetes/log-capture-plan.js +9 -0
- package/dist/kubernetes/log-timestamp.d.ts +2 -0
- package/dist/kubernetes/log-timestamp.js +6 -0
- package/dist/kubernetes/pod-log-client.d.ts +25 -0
- package/dist/kubernetes/pod-log-client.js +12 -0
- package/dist/kubernetes/pod-log-datasource.d.ts +17 -0
- package/dist/kubernetes/pod-log-datasource.js +31 -0
- package/dist/kubernetes/pod-log.d.ts +52 -0
- package/dist/kubernetes/pod-log.js +121 -0
- package/dist/kubernetes/pod.d.ts +61 -0
- package/dist/kubernetes/pod.js +8 -0
- package/dist/kubernetes/port-forward.d.ts +42 -0
- package/dist/kubernetes/port-forward.js +10 -0
- package/dist/kubernetes/service-port-forward.d.ts +29 -0
- package/dist/kubernetes/service-port-forward.js +11 -0
- package/dist/kubernetes/service.d.ts +31 -0
- package/dist/kubernetes/service.js +17 -0
- package/dist/mysql/client.d.ts +36 -0
- package/dist/mysql/client.js +13 -0
- package/dist/mysql/index.d.ts +3 -0
- package/dist/mysql/index.js +18 -0
- package/dist/mysql/pod.d.ts +7 -0
- package/dist/mysql/pod.js +8 -0
- package/dist/mysql/target.d.ts +12 -0
- package/dist/mysql/target.js +6 -0
- package/dist/mysql/types.d.ts +16 -0
- package/dist/mysql/types.js +1 -0
- package/dist/opensearch/client.d.ts +62 -0
- package/dist/opensearch/client.js +12 -0
- package/dist/opensearch/endpoint.d.ts +16 -0
- package/dist/opensearch/endpoint.js +6 -0
- package/dist/opensearch/index.d.ts +3 -0
- package/dist/opensearch/index.js +17 -0
- package/dist/opensearch/types.d.ts +8 -0
- package/dist/opensearch/types.js +1 -0
- package/dist/process/index.d.ts +13 -0
- package/dist/process/index.js +8 -0
- package/dist/redis/client.d.ts +90 -0
- package/dist/redis/client.js +14 -0
- package/dist/redis/index.d.ts +3 -0
- package/dist/redis/index.js +24 -0
- package/dist/redis/key-stats.d.ts +27 -0
- package/dist/redis/key-stats.js +8 -0
- package/dist/redis/topology.d.ts +23 -0
- package/dist/redis/topology.js +6 -0
- package/dist/transport/index.d.ts +40 -0
- package/dist/transport/index.js +12 -0
- package/package.json +96 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Executor } from "./executor";
|
|
2
|
+
import type { KubernetesEndpoint } from "./endpoint";
|
|
3
|
+
import { type KubernetesPod } from "./pod";
|
|
4
|
+
export interface KubernetesServicePort {
|
|
5
|
+
name?: string;
|
|
6
|
+
port: number;
|
|
7
|
+
targetPort?: string | number;
|
|
8
|
+
}
|
|
9
|
+
export interface KubernetesService {
|
|
10
|
+
kind: "service";
|
|
11
|
+
namespace: string;
|
|
12
|
+
name: string;
|
|
13
|
+
clusterIP?: string;
|
|
14
|
+
selector: Record<string, string>;
|
|
15
|
+
ports: KubernetesServicePort[];
|
|
16
|
+
}
|
|
17
|
+
export declare function parseServices(raw: string, defaultNamespace: string): KubernetesService[];
|
|
18
|
+
/** 只接受 Kubernetes 的稳定 Service DNS 形态,避免把普通域名误判成集群资源。 */
|
|
19
|
+
export declare function serviceIdentity(host: string, defaultNamespace: string): {
|
|
20
|
+
name: string;
|
|
21
|
+
namespace: string;
|
|
22
|
+
} | undefined;
|
|
23
|
+
export declare function findService(services: readonly KubernetesService[], endpoint: KubernetesEndpoint, defaultNamespace: string): KubernetesService | undefined;
|
|
24
|
+
/** Pod → Service 保持一对多;选择哪个 Service/port 是调用方的配置确认职责。 */
|
|
25
|
+
export declare function findServicesForPod(services: readonly KubernetesService[], pod: KubernetesPod): KubernetesService[];
|
|
26
|
+
/** Service → Pod 由 Kubernetes selector 决定,不让上层用 Pod 名称前缀猜测。 */
|
|
27
|
+
export declare function findPodsForService(services: readonly KubernetesService[], pods: readonly KubernetesPod[], serviceName: string, namespace: string): KubernetesPod[];
|
|
28
|
+
export declare function listServiceNetwork(executor: Executor, namespace: string): Promise<{
|
|
29
|
+
services: KubernetesService[];
|
|
30
|
+
pods: KubernetesPod[];
|
|
31
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findPodsForService,
|
|
3
|
+
findService,
|
|
4
|
+
findServicesForPod,
|
|
5
|
+
listServiceNetwork,
|
|
6
|
+
parseServices,
|
|
7
|
+
serviceIdentity
|
|
8
|
+
} from "../chunk-j46x7j7c.js";
|
|
9
|
+
import"../chunk-6fnhzhdb.js";
|
|
10
|
+
export {
|
|
11
|
+
serviceIdentity,
|
|
12
|
+
parseServices,
|
|
13
|
+
listServiceNetwork,
|
|
14
|
+
findServicesForPod,
|
|
15
|
+
findService,
|
|
16
|
+
findPodsForService
|
|
17
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Client } from "../client";
|
|
2
|
+
import { type Connection, type ConnectionOptions } from "mysql2/promise";
|
|
3
|
+
import type { Database, DatabaseTarget, DatabaseRow } from "./types";
|
|
4
|
+
import type { ConnectionSource, ClientLifecycle } from "../datasource";
|
|
5
|
+
import { type Transport } from "../transport";
|
|
6
|
+
export interface MysqlDatabaseOptions extends ClientLifecycle {
|
|
7
|
+
connectTimeoutMs: number;
|
|
8
|
+
queryTimeoutMs: number;
|
|
9
|
+
}
|
|
10
|
+
type ConnectionFactory = (options: ConnectionOptions) => Promise<Connection>;
|
|
11
|
+
/** SQL is executed once; only native connection establishment may advance to another transport. */
|
|
12
|
+
export declare class MysqlDatabase implements Database {
|
|
13
|
+
#private;
|
|
14
|
+
private readonly transports;
|
|
15
|
+
private readonly options;
|
|
16
|
+
private readonly connect;
|
|
17
|
+
constructor(transports: readonly Transport[], options: MysqlDatabaseOptions, connect?: ConnectionFactory);
|
|
18
|
+
query(target: DatabaseTarget, sql: string, values: readonly unknown[]): Promise<DatabaseRow[]>;
|
|
19
|
+
initialize(target: DatabaseTarget): Promise<void>;
|
|
20
|
+
queryOne(target: DatabaseTarget, sql: string, values: readonly unknown[]): Promise<DatabaseRow | undefined>;
|
|
21
|
+
close(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
/** A datasource-bound MySQL client; the protocol adapter still supports explicit multi-target diagnostics. */
|
|
24
|
+
export declare class MysqlClient<Target extends DatabaseTarget = DatabaseTarget> implements Client {
|
|
25
|
+
#private;
|
|
26
|
+
private readonly source;
|
|
27
|
+
private readonly options;
|
|
28
|
+
readonly signal: AbortSignal;
|
|
29
|
+
constructor(source: ConnectionSource<Target>, options: MysqlDatabaseOptions);
|
|
30
|
+
initialize(): Promise<void>;
|
|
31
|
+
get database(): Database;
|
|
32
|
+
get target(): Target;
|
|
33
|
+
dispose(): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export declare function openMysql<Target extends DatabaseTarget>(source: ConnectionSource<Target>, options: MysqlDatabaseOptions): Promise<MysqlClient<Target>>;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MysqlClient,
|
|
3
|
+
MysqlDatabase,
|
|
4
|
+
openMysql
|
|
5
|
+
} from "../chunk-mkhyty75.js";
|
|
6
|
+
import"../chunk-v3hxvnrc.js";
|
|
7
|
+
import {
|
|
8
|
+
parseMysqlEnvTarget
|
|
9
|
+
} from "../chunk-qq77x9ek.js";
|
|
10
|
+
import"../chunk-pfar9cm3.js";
|
|
11
|
+
import"../chunk-s06hs7a8.js";
|
|
12
|
+
import"../chunk-xy4g56g4.js";
|
|
13
|
+
export {
|
|
14
|
+
parseMysqlEnvTarget,
|
|
15
|
+
openMysql,
|
|
16
|
+
MysqlDatabase,
|
|
17
|
+
MysqlClient
|
|
18
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DatabaseRow, DatabaseTarget } from "./types";
|
|
2
|
+
import type { PodPythonTransport } from "../transport";
|
|
3
|
+
export declare function preparePodSql(sql: string, values: readonly unknown[]): string;
|
|
4
|
+
export declare function queryMysqlViaPod(transport: PodPythonTransport, target: DatabaseTarget, sql: string, values: readonly unknown[], options: {
|
|
5
|
+
connectTimeoutMs: number;
|
|
6
|
+
queryTimeoutMs: number;
|
|
7
|
+
}): Promise<DatabaseRow[]>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DatabaseIdentity, DatabaseTarget } from "./types";
|
|
2
|
+
export interface MysqlTarget extends DatabaseTarget {
|
|
3
|
+
credentialSource: "service-env" | "profile";
|
|
4
|
+
}
|
|
5
|
+
export interface DatabaseEnvTargetOptions {
|
|
6
|
+
label: string;
|
|
7
|
+
prefix: string;
|
|
8
|
+
fallback?: DatabaseIdentity;
|
|
9
|
+
defaultPort?: number;
|
|
10
|
+
}
|
|
11
|
+
/** Parse a database endpoint and credentials from a service environment dump. */
|
|
12
|
+
export declare function parseMysqlEnvTarget(raw: string, options: DatabaseEnvTargetOptions): MysqlTarget;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface DatabaseIdentity {
|
|
2
|
+
user: string;
|
|
3
|
+
password: string;
|
|
4
|
+
}
|
|
5
|
+
export interface DatabaseTarget extends DatabaseIdentity {
|
|
6
|
+
host: string;
|
|
7
|
+
port: number;
|
|
8
|
+
database: string;
|
|
9
|
+
}
|
|
10
|
+
export type DatabaseRow = Record<string, unknown>;
|
|
11
|
+
/** Storage-neutral operations shared by infrastructure consumers. */
|
|
12
|
+
export interface Database {
|
|
13
|
+
query(target: DatabaseTarget, sql: string, values: readonly unknown[]): Promise<DatabaseRow[]>;
|
|
14
|
+
queryOne(target: DatabaseTarget, sql: string, values: readonly unknown[]): Promise<DatabaseRow | undefined>;
|
|
15
|
+
close(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../chunk-pfar9cm3.js";
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Client as ManagedClient } from "../client";
|
|
2
|
+
import type { ConnectionSource, ClientLifecycle } from "../datasource";
|
|
3
|
+
import type { SearchEngine, SearchQuery, SearchResult } from "./types";
|
|
4
|
+
export interface OpenSearchAuth {
|
|
5
|
+
username?: string;
|
|
6
|
+
password?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface OpenSearchOptions {
|
|
9
|
+
node: string;
|
|
10
|
+
auth: OpenSearchAuth;
|
|
11
|
+
requestTimeoutMs?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface OpenSearchClientApi {
|
|
14
|
+
count(params: Record<string, unknown>): Promise<{
|
|
15
|
+
body: {
|
|
16
|
+
count: number;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
search(params: Record<string, unknown>): Promise<{
|
|
20
|
+
body: SearchResult;
|
|
21
|
+
}>;
|
|
22
|
+
ping(params?: Record<string, unknown>): Promise<unknown>;
|
|
23
|
+
transport?: {
|
|
24
|
+
request(params: {
|
|
25
|
+
method: string;
|
|
26
|
+
path: string;
|
|
27
|
+
querystring?: Record<string, unknown>;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
body: unknown;
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
32
|
+
close(): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
/** OpenSearch-specific read APIs stay outside the engine-neutral SearchEngine contract. */
|
|
35
|
+
export interface OpenSearchReadApi extends SearchEngine {
|
|
36
|
+
request(path: string, query?: SearchQuery): Promise<unknown>;
|
|
37
|
+
}
|
|
38
|
+
export declare function isOpenSearchReadApi(search: SearchEngine): search is OpenSearchReadApi;
|
|
39
|
+
/** Official OpenSearch client behind the engine-neutral SearchEngine contract. */
|
|
40
|
+
export declare class OpenSearchEngine implements OpenSearchReadApi {
|
|
41
|
+
private readonly client;
|
|
42
|
+
constructor(options: OpenSearchOptions, client?: OpenSearchClientApi);
|
|
43
|
+
count(index: string, query: SearchQuery): Promise<number>;
|
|
44
|
+
search(index: string, body: SearchQuery): Promise<SearchResult>;
|
|
45
|
+
request(path: string, query?: SearchQuery): Promise<unknown>;
|
|
46
|
+
ping(): Promise<unknown>;
|
|
47
|
+
close(): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
export declare class OpenSearchClient implements ManagedClient, OpenSearchReadApi {
|
|
50
|
+
#private;
|
|
51
|
+
private readonly source;
|
|
52
|
+
readonly signal: AbortSignal;
|
|
53
|
+
constructor(source: ConnectionSource<OpenSearchOptions>, lifecycle?: ClientLifecycle);
|
|
54
|
+
initialize(): Promise<void>;
|
|
55
|
+
count(index: string, query: SearchQuery): Promise<number>;
|
|
56
|
+
search(index: string, body: SearchQuery): Promise<SearchResult>;
|
|
57
|
+
request(path: string, query?: SearchQuery): Promise<unknown>;
|
|
58
|
+
ping(): Promise<unknown>;
|
|
59
|
+
close(): Promise<void>;
|
|
60
|
+
dispose(): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
export declare function openOpenSearch(source: ConnectionSource<OpenSearchOptions>, lifecycle?: ClientLifecycle): Promise<OpenSearchClient>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ParsedOpenSearchEndpoint {
|
|
2
|
+
url: string;
|
|
3
|
+
safeUrl: string;
|
|
4
|
+
safeEndpoint: string;
|
|
5
|
+
host: string;
|
|
6
|
+
port: number;
|
|
7
|
+
scheme: "http" | "https";
|
|
8
|
+
schemeExplicit: boolean;
|
|
9
|
+
username?: string;
|
|
10
|
+
password?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 连接串只在执行态保留 userinfo;任何可记录的 endpoint 必须使用 safeUrl。
|
|
14
|
+
* OPENSEARCH_ENDPOINTS 常见为逗号分隔,这里选择第一个节点作为稳定访问入口。
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseOpenSearchEndpoint(value: string): ParsedOpenSearchEndpoint;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseOpenSearchEndpoint
|
|
3
|
+
} from "../chunk-s1sjyem7.js";
|
|
4
|
+
import"../chunk-djk4kmxb.js";
|
|
5
|
+
import {
|
|
6
|
+
OpenSearchClient,
|
|
7
|
+
OpenSearchEngine,
|
|
8
|
+
isOpenSearchReadApi,
|
|
9
|
+
openOpenSearch
|
|
10
|
+
} from "../chunk-w3a4p6jm.js";
|
|
11
|
+
export {
|
|
12
|
+
parseOpenSearchEndpoint,
|
|
13
|
+
openOpenSearch,
|
|
14
|
+
isOpenSearchReadApi,
|
|
15
|
+
OpenSearchEngine,
|
|
16
|
+
OpenSearchClient
|
|
17
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type SearchQuery = Record<string, unknown>;
|
|
2
|
+
export type SearchResult = Record<string, unknown>;
|
|
3
|
+
/** Engine-neutral operations used by collect domains. */
|
|
4
|
+
export interface SearchEngine {
|
|
5
|
+
count(index: string, query: SearchQuery): Promise<number>;
|
|
6
|
+
search(index: string, body: SearchQuery): Promise<SearchResult>;
|
|
7
|
+
close?(): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../chunk-djk4kmxb.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface RuntimeProcess {
|
|
2
|
+
stdout: ReadableStream<Uint8Array>;
|
|
3
|
+
stderr: ReadableStream<Uint8Array>;
|
|
4
|
+
exited: Promise<number>;
|
|
5
|
+
kill(): void;
|
|
6
|
+
}
|
|
7
|
+
export interface SpawnProcessOptions {
|
|
8
|
+
stdin?: string | Uint8Array;
|
|
9
|
+
env?: NodeJS.ProcessEnv;
|
|
10
|
+
}
|
|
11
|
+
/** 使用 Node-compatible 子进程 API,不要求调用方使用 Bun runtime。 */
|
|
12
|
+
export declare function spawnProcess(argv: string[], opts?: SpawnProcessOptions): RuntimeProcess;
|
|
13
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Client } from "../client";
|
|
2
|
+
import type { ConnectionSource, ClientLifecycle } from "../datasource";
|
|
3
|
+
import type { TcpTransport } from "../transport";
|
|
4
|
+
import { createClient, type RedisClientType } from "@redis/client";
|
|
5
|
+
export interface RedisEndpoint {
|
|
6
|
+
host: string;
|
|
7
|
+
port: number;
|
|
8
|
+
}
|
|
9
|
+
export interface RedisMappedEndpoint extends RedisEndpoint {
|
|
10
|
+
servername?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface RedisCredentials {
|
|
13
|
+
username?: string;
|
|
14
|
+
password?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface RedisConnectionConfig extends RedisCredentials {
|
|
17
|
+
database: number;
|
|
18
|
+
useSsl: boolean;
|
|
19
|
+
timeoutMs: number;
|
|
20
|
+
}
|
|
21
|
+
export type RedisEndpointMapper = (endpoint: RedisEndpoint) => Promise<RedisMappedEndpoint>;
|
|
22
|
+
type NodeRedisClient = RedisClientType;
|
|
23
|
+
type NodeRedisClientFactory = (options: Parameters<typeof createClient>[0]) => NodeRedisClient;
|
|
24
|
+
export interface RedisManagedConnection extends RedisConnectionApi {
|
|
25
|
+
readonly isReady: boolean;
|
|
26
|
+
close(): void;
|
|
27
|
+
}
|
|
28
|
+
export type RedisConnectionFactory = (endpoint: RedisEndpoint, mapped: RedisMappedEndpoint, config: RedisConnectionConfig) => Promise<RedisManagedConnection>;
|
|
29
|
+
/** Redis INFO wire 文本解析;协议适配留在 infra,领域层只接收结构化字段。 */
|
|
30
|
+
export declare function parseRedisInfo(raw: string): Record<string, unknown>;
|
|
31
|
+
export interface RedisConnectionApi {
|
|
32
|
+
readonly endpoint: RedisEndpoint;
|
|
33
|
+
ping(): Promise<string>;
|
|
34
|
+
info(section?: string): Promise<Record<string, unknown>>;
|
|
35
|
+
dbSize(): Promise<number>;
|
|
36
|
+
command(args: string[]): Promise<unknown>;
|
|
37
|
+
pipeline(commands: string[][]): Promise<unknown[]>;
|
|
38
|
+
scan(cursor: string, count: number): Promise<{
|
|
39
|
+
cursor: string;
|
|
40
|
+
keys: string[];
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
export interface RedisAccessApi {
|
|
44
|
+
connection(endpoint: RedisEndpoint, database: number, credentials?: RedisCredentials): Promise<RedisConnectionApi>;
|
|
45
|
+
close(): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
export declare class RedisConnection implements RedisManagedConnection {
|
|
48
|
+
#private;
|
|
49
|
+
readonly endpoint: RedisEndpoint;
|
|
50
|
+
private readonly client;
|
|
51
|
+
private readonly timeoutMs;
|
|
52
|
+
private readonly lastError;
|
|
53
|
+
private constructor();
|
|
54
|
+
static connect(endpoint: RedisEndpoint, mapped: RedisMappedEndpoint, config: RedisConnectionConfig, clientFactory?: NodeRedisClientFactory): Promise<RedisConnection>;
|
|
55
|
+
get isReady(): boolean;
|
|
56
|
+
ping(): Promise<string>;
|
|
57
|
+
info(section?: string): Promise<Record<string, unknown>>;
|
|
58
|
+
dbSize(): Promise<number>;
|
|
59
|
+
command(args: string[]): Promise<unknown>;
|
|
60
|
+
pipeline(commands: string[][]): Promise<unknown[]>;
|
|
61
|
+
scan(cursor: string, count: number): Promise<{
|
|
62
|
+
cursor: string;
|
|
63
|
+
keys: string[];
|
|
64
|
+
}>;
|
|
65
|
+
close(): void;
|
|
66
|
+
}
|
|
67
|
+
export declare class RedisAccess implements RedisAccessApi {
|
|
68
|
+
#private;
|
|
69
|
+
private readonly transport;
|
|
70
|
+
private readonly baseConfig;
|
|
71
|
+
private readonly connectionFactory;
|
|
72
|
+
constructor(transport: TcpTransport, baseConfig: Omit<RedisConnectionConfig, "database">, connectionFactory?: RedisConnectionFactory);
|
|
73
|
+
connection(endpoint: RedisEndpoint, database: number, credentials?: RedisCredentials): Promise<RedisManagedConnection>;
|
|
74
|
+
close(): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
export interface RedisDataSourceTarget extends RedisConnectionConfig {
|
|
77
|
+
endpoints: RedisEndpoint[];
|
|
78
|
+
}
|
|
79
|
+
export declare class RedisClient implements Client {
|
|
80
|
+
#private;
|
|
81
|
+
private readonly source;
|
|
82
|
+
readonly signal: AbortSignal;
|
|
83
|
+
constructor(source: ConnectionSource<RedisDataSourceTarget>, lifecycle?: ClientLifecycle);
|
|
84
|
+
initialize(): Promise<void>;
|
|
85
|
+
get access(): RedisAccess;
|
|
86
|
+
get target(): RedisDataSourceTarget;
|
|
87
|
+
dispose(): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
export declare function openRedis(source: ConnectionSource<RedisDataSourceTarget>, lifecycle?: ClientLifecycle): Promise<RedisClient>;
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
collectRedisKeyStats,
|
|
3
|
+
redisGroupedSampleSizes
|
|
4
|
+
} from "../chunk-jr9y0ghr.js";
|
|
5
|
+
import {
|
|
6
|
+
discoverRedisTopology
|
|
7
|
+
} from "../chunk-c6z919qb.js";
|
|
8
|
+
import {
|
|
9
|
+
RedisAccess,
|
|
10
|
+
RedisClient,
|
|
11
|
+
RedisConnection,
|
|
12
|
+
openRedis,
|
|
13
|
+
parseRedisInfo
|
|
14
|
+
} from "../chunk-ajhdd4hp.js";
|
|
15
|
+
export {
|
|
16
|
+
redisGroupedSampleSizes,
|
|
17
|
+
parseRedisInfo,
|
|
18
|
+
openRedis,
|
|
19
|
+
discoverRedisTopology,
|
|
20
|
+
collectRedisKeyStats,
|
|
21
|
+
RedisConnection,
|
|
22
|
+
RedisClient,
|
|
23
|
+
RedisAccess
|
|
24
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RedisConnectionApi } from "./client";
|
|
2
|
+
export interface RedisKeyStat {
|
|
3
|
+
key: string;
|
|
4
|
+
type: string;
|
|
5
|
+
memoryBytes: number;
|
|
6
|
+
ttlMs: number;
|
|
7
|
+
length: number | null;
|
|
8
|
+
}
|
|
9
|
+
export interface RedisKeyStatsOptions {
|
|
10
|
+
maxKeys: number;
|
|
11
|
+
maxKeysPerSecond: number;
|
|
12
|
+
scanCount: number;
|
|
13
|
+
pipelineKeys: number;
|
|
14
|
+
memorySamples: number;
|
|
15
|
+
onSelectionProgress?: (selected: number, limit: number) => void;
|
|
16
|
+
onProgress?: (inspected: number, limit: number) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface RedisKeyStatsResult {
|
|
19
|
+
totalKeys: number;
|
|
20
|
+
visitedKeys: number;
|
|
21
|
+
inspectedKeys: number;
|
|
22
|
+
scanComplete: boolean;
|
|
23
|
+
keys: RedisKeyStat[];
|
|
24
|
+
}
|
|
25
|
+
export declare function redisGroupedSampleSizes(totalKeys: number, targetSamples: number): number[];
|
|
26
|
+
/** redis-cli keyStats 的受预算实现:有界选择 key,并用 pipeline 检查元数据。 */
|
|
27
|
+
export declare function collectRedisKeyStats(client: RedisConnectionApi, options: RedisKeyStatsOptions): Promise<RedisKeyStatsResult>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { RedisAccessApi, RedisCredentials, RedisEndpoint } from "./client";
|
|
2
|
+
export interface RedisTopologyConfig extends RedisCredentials {
|
|
3
|
+
endpoints: RedisEndpoint[];
|
|
4
|
+
database: number;
|
|
5
|
+
clusterType: "single" | "sentinel" | "cluster";
|
|
6
|
+
sentinelHosts: RedisEndpoint[];
|
|
7
|
+
sentinelMasterName: string;
|
|
8
|
+
sentinelUsername?: string;
|
|
9
|
+
sentinelPassword?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface RedisSlotRange {
|
|
12
|
+
start: number;
|
|
13
|
+
end: number;
|
|
14
|
+
master: RedisEndpoint;
|
|
15
|
+
replicas: RedisEndpoint[];
|
|
16
|
+
}
|
|
17
|
+
export interface RedisTopology {
|
|
18
|
+
clusterType: "single" | "sentinel" | "cluster";
|
|
19
|
+
masters: RedisEndpoint[];
|
|
20
|
+
replicas: RedisEndpoint[];
|
|
21
|
+
slotRanges: RedisSlotRange[];
|
|
22
|
+
}
|
|
23
|
+
export declare function discoverRedisTopology(access: RedisAccessApi, config: RedisTopologyConfig): Promise<RedisTopology>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface Endpoint {
|
|
2
|
+
host: string;
|
|
3
|
+
port: number;
|
|
4
|
+
servername?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface TcpTransport {
|
|
7
|
+
readonly kind: "tcp";
|
|
8
|
+
readonly name: string;
|
|
9
|
+
connect(endpoint: Endpoint): Promise<Endpoint>;
|
|
10
|
+
}
|
|
11
|
+
export declare class DirectTransport implements TcpTransport {
|
|
12
|
+
readonly kind = "tcp";
|
|
13
|
+
readonly name = "direct";
|
|
14
|
+
connect(endpoint: Endpoint): Promise<Endpoint>;
|
|
15
|
+
}
|
|
16
|
+
/** The supplied forwarder owns port allocation and cleanup; external endpoints may stay direct. */
|
|
17
|
+
export declare class PortForwardTransport implements TcpTransport {
|
|
18
|
+
private readonly forward;
|
|
19
|
+
readonly kind = "tcp";
|
|
20
|
+
readonly name = "port-forward";
|
|
21
|
+
constructor(forward: (endpoint: Endpoint) => Promise<Endpoint>);
|
|
22
|
+
connect(endpoint: Endpoint): Promise<Endpoint>;
|
|
23
|
+
}
|
|
24
|
+
export interface PodRunOptions {
|
|
25
|
+
stdin: string;
|
|
26
|
+
timeoutMs: number;
|
|
27
|
+
}
|
|
28
|
+
export type PodRunner = (command: readonly string[], options: PodRunOptions) => Promise<string>;
|
|
29
|
+
/** A Python-capable Pod path. Protocol code supplies the script; the host enforces access. */
|
|
30
|
+
export declare class PodPythonTransport {
|
|
31
|
+
private readonly exec;
|
|
32
|
+
private readonly python;
|
|
33
|
+
readonly kind = "python";
|
|
34
|
+
readonly name = "pod-python";
|
|
35
|
+
constructor(exec: PodRunner, python?: string);
|
|
36
|
+
run(script: string, input: unknown, timeoutMs: number): Promise<string>;
|
|
37
|
+
}
|
|
38
|
+
export type Transport = TcpTransport | PodPythonTransport;
|
|
39
|
+
/** Only failure to establish a connection permits a route change; never replay protocol operations. */
|
|
40
|
+
export declare function isConnectionNetworkError(error: unknown): boolean;
|