sqlite-executor 4.0.2 → 4.0.4

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.
@@ -12,6 +12,8 @@ export interface PipelineEngineOptions {
12
12
  logger?: { error?: (...args: any[]) => void };
13
13
  /** 管线化批量大小,控制一次 stdin.write 合并几条语句,默认 10 */
14
14
  batchSize?: number;
15
+ /** 最大 inflight 任务数,默认 50 */
16
+ maxInflight?: number;
15
17
  /** 任务超时时的回调 */
16
18
  onTaskTimeout?: (task: any) => void;
17
19
  }
@@ -11,8 +11,14 @@ export declare class ProcessManager {
11
11
  * @param options.initMode 初始化模式
12
12
  * - `"wal"` (默认):启动时通过 `-cmd` 设置 WAL 模式 + busy_timeout
13
13
  * - `"none"`:不添加任何初始化参数(适用于 reader,直接继承数据库已有 WAL 模式)
14
+ * @param options.onDrain drain 回调,当 stdin pipe 重新可写时调用
14
15
  */
15
- constructor(options?: { binary?: string; database?: string; initMode?: "wal" | "none" });
16
+ constructor(options?: {
17
+ binary?: string;
18
+ database?: string;
19
+ initMode?: "wal" | "none";
20
+ onDrain?: () => void;
21
+ });
16
22
 
17
23
  /** 当前使用的 sqlite3 可执行文件路径 */
18
24
  get binary(): string;
@@ -20,6 +26,12 @@ export declare class ProcessManager {
20
26
  /** 底层子进程实例,未启动时为 null */
21
27
  get process(): ChildProcess | null;
22
28
 
29
+ /**
30
+ * drain 状态,true 表示 OS pipe 已满,应暂停写入 stdin。
31
+ * 当 pipe 重新可写时 drain 事件触发,draining 恢复为 false。
32
+ */
33
+ get draining(): boolean;
34
+
23
35
  /**
24
36
  * 启动子进程(json 模式),返回 ChildProcess 实例。
25
37
  * @throws {Error} 如果 binary 路径为空或文件不存在
@@ -29,6 +41,9 @@ export declare class ProcessManager {
29
41
  /** 向子进程的 stdin 写入数据 */
30
42
  write(data: string): void;
31
43
 
44
+ /** 注册 drain 回调,当 pipe 重新可写时被调用。 */
45
+ setOnDrainCallback(fn: () => void): void;
46
+
32
47
  /**
33
48
  * 终止子进程。
34
49
  * 先尝试 SIGTERM,3 秒后未退出则 SIGKILL。
@@ -1,3 +1,5 @@
1
+ import { Metrics } from "./metrics.mts";
2
+
1
3
  /**
2
4
  * 单个 sqlite3 进程 Worker,支持管线化(pipelining)。
3
5
  *
@@ -18,6 +20,8 @@ export class TaskWorker {
18
20
  * @param options.name Worker 名称,用于日志和调试
19
21
  * @param options.initMode 子进程初始化模式(参考 ProcessManager)
20
22
  * @param options.batchSize 管线化批量大小,默认 10
23
+ * @param options.maxInflight 最大 inflight 任务数,默认 50
24
+ * @param options.metrics 指标收集器
21
25
  */
22
26
  constructor(options: {
23
27
  binary: string;
@@ -27,6 +31,8 @@ export class TaskWorker {
27
31
  name?: string;
28
32
  initMode?: "wal" | "none";
29
33
  batchSize?: number;
34
+ maxInflight?: number;
35
+ metrics?: Metrics;
30
36
  });
31
37
 
32
38
  /** Worker 名称 */