@yydb/yyds 0.0.17 → 0.0.20

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yydb/yyds",
3
- "version": "0.0.17",
3
+ "version": "0.0.20",
4
4
  "description": "Node.js facade, CLI, and native bindings for local YYDS nodes.",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",
@@ -59,14 +59,14 @@
59
59
  "access": "public"
60
60
  },
61
61
  "optionalDependencies": {
62
- "@yydb/yyds-win32-x64": "0.0.17",
63
- "@yydb/yyds-linux-x64": "0.0.17",
64
- "@yydb/yyds-darwin-x64": "0.0.17",
65
- "@yydb/yyds-darwin-arm64": "0.0.17"
62
+ "@yydb/yyds-win32-x64": "0.0.20",
63
+ "@yydb/yyds-linux-x64": "0.0.20",
64
+ "@yydb/yyds-darwin-x64": "0.0.20",
65
+ "@yydb/yyds-darwin-arm64": "0.0.20"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/node": "^22.15.0",
69
- "@yydb/yyds-webui": "0.0.17",
69
+ "@yydb/yyds-webui": "0.0.20",
70
70
  "typescript": "^5.9.2"
71
71
  },
72
72
  "engines": {
package/src/bindings.ts CHANGED
@@ -6,14 +6,30 @@ export interface YydsBindings {
6
6
  NodeLeaseHandle: {
7
7
  acquire(dataDir: string, identity: unknown): unknown;
8
8
  };
9
- LocalExecutorHandle: new (dataDir: string) => unknown;
9
+ LocalExecutorHandle: new (dataDir: string, catalogPath?: string | null) => unknown;
10
10
  RedisServiceHandle: new (
11
11
  lease: unknown,
12
12
  port: number,
13
13
  executor: unknown,
14
14
  ) => RedisServiceBinding;
15
- PgsqlServiceHandle: new (lease: unknown, port: number) => PgsqlServiceBinding;
16
- MysqlServiceHandle: new (lease: unknown, port: number) => MysqlServiceBinding;
15
+ PgsqlServiceHandle: {
16
+ new (lease: unknown, port: number): PgsqlServiceBinding;
17
+ start_with_executor(
18
+ lease: unknown,
19
+ port: number,
20
+ executor: unknown,
21
+ catalogPath: string,
22
+ ): PgsqlServiceBinding;
23
+ };
24
+ MysqlServiceHandle: {
25
+ new (lease: unknown, port: number): MysqlServiceBinding;
26
+ start_with_executor(
27
+ lease: unknown,
28
+ port: number,
29
+ executor: unknown,
30
+ catalogPath: string,
31
+ ): MysqlServiceBinding;
32
+ };
17
33
  MongoServiceHandle: new (
18
34
  lease: unknown,
19
35
  port: number,
@@ -9,6 +9,7 @@ export interface StartNodeOptions {
9
9
  dataDir: string;
10
10
  clusterId: string;
11
11
  nodeId: string;
12
+ catalogPath?: string;
12
13
  redisPort?: number;
13
14
  pgsqlPort?: number;
14
15
  mysqlPort?: number;
@@ -55,6 +56,10 @@ export function parseStartOptions(protocol: YydsProtocol, args: string[]): Start
55
56
  options.nodeId = args[++index] ?? "";
56
57
  continue;
57
58
  }
59
+ if (argument === "--catalog-path") {
60
+ options.catalogPath = args[++index] ?? "";
61
+ continue;
62
+ }
58
63
  if (argument === "--redis-port") {
59
64
  options.redisPort = Number(args[++index]);
60
65
  continue;
@@ -81,6 +86,10 @@ export function parseStartOptions(protocol: YydsProtocol, args: string[]): Start
81
86
  if (!options.dataDir || !options.clusterId || !options.nodeId) {
82
87
  throw new Error("start requires --data-dir, --cluster-id, and --node-id");
83
88
  }
89
+ if (options.catalogPath !== undefined && options.catalogPath.length === 0) {
90
+ // 空字符串视为未提供;避免将空值传给 Rust。
91
+ options.catalogPath = undefined;
92
+ }
84
93
  const defaultPort = defaultPorts[protocol];
85
94
  if (protocol === "mysql" && options.mysqlPort === undefined && defaultPort !== undefined) {
86
95
  options.mysqlPort = defaultPort;
@@ -88,6 +97,7 @@ export function parseStartOptions(protocol: YydsProtocol, args: string[]): Start
88
97
  if (protocol === "postgresql" && options.pgsqlPort === undefined && defaultPort !== undefined) {
89
98
  options.pgsqlPort = defaultPort;
90
99
  }
100
+ void portFlags; // 变量声明用于协议完整性校验,运行时不再读取
91
101
  return options;
92
102
  }
93
103
 
@@ -96,20 +106,37 @@ export async function runNodeStart(options: StartNodeOptions): Promise<void> {
96
106
  const native = loadYydsNative();
97
107
  const identity = new native.NodeIdentityHandle(options.clusterId, options.nodeId);
98
108
  const lease = native.NodeLeaseHandle.acquire(options.dataDir, identity);
99
- const executor = new native.LocalExecutorHandle(options.dataDir);
109
+ const executor = new native.LocalExecutorHandle(options.dataDir, options.catalogPath);
100
110
  const redis = new native.RedisServiceHandle(
101
111
  lease,
102
112
  options.redisPort ?? DEFAULT_REDIS_PORT,
103
113
  executor,
104
114
  );
115
+
116
+ // SQL runtimes 仅在提供了 catalog 时启动完整执行路径;否则保持协议壳。
117
+ const hasRuntime = options.catalogPath !== undefined;
105
118
  const pgsql =
106
119
  options.pgsqlPort === undefined
107
120
  ? undefined
108
- : new native.PgsqlServiceHandle(lease, options.pgsqlPort);
121
+ : hasRuntime
122
+ ? native.PgsqlServiceHandle.start_with_executor(
123
+ lease,
124
+ options.pgsqlPort,
125
+ executor,
126
+ options.catalogPath!,
127
+ )
128
+ : new native.PgsqlServiceHandle(lease, options.pgsqlPort);
109
129
  const mysql =
110
130
  options.mysqlPort === undefined
111
131
  ? undefined
112
- : new native.MysqlServiceHandle(lease, options.mysqlPort);
132
+ : hasRuntime
133
+ ? native.MysqlServiceHandle.start_with_executor(
134
+ lease,
135
+ options.mysqlPort,
136
+ executor,
137
+ options.catalogPath!,
138
+ )
139
+ : new native.MysqlServiceHandle(lease, options.mysqlPort);
113
140
  const mongo =
114
141
  options.mongoPort === undefined
115
142
  ? undefined
@@ -131,8 +158,9 @@ export async function runNodeStart(options: StartNodeOptions): Promise<void> {
131
158
  };
132
159
  native.nodeWriteRuntimeStatus(options.dataDir, JSON.stringify(runtime));
133
160
 
161
+ const runtimeTag = hasRuntime ? "sql-runtime" : "protocol-only";
134
162
  process.stdout.write(
135
- `yyds running pid=${runtime.pid} redis=${runtime.redisAddress} pgsql=${runtime.pgsqlAddress ?? "null"} mysql=${runtime.mysqlAddress ?? "null"} mongo=${mongo?.address() ?? "null"} wire=${runtime.wireAddress ?? "null"}\n`,
163
+ `yyds running pid=${runtime.pid} mode=${runtimeTag} redis=${runtime.redisAddress} pgsql=${runtime.pgsqlAddress ?? "null"} mysql=${runtime.mysqlAddress ?? "null"} mongo=${mongo?.address() ?? "null"} wire=${runtime.wireAddress ?? "null"}\n`,
136
164
  );
137
165
 
138
166
  while (true) {