xrootd 0.1.10 → 0.1.12
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 +2 -2
- package/dist/index.cjs +93 -10
- package/dist/index.d.cts +314 -7
- package/dist/index.d.mts +314 -7
- package/dist/index.mjs +93 -10
- package/libs/darwin-arm64/libXrdCl.6.dylib +0 -0
- package/libs/darwin-arm64/libXrdCrypto.6.dylib +0 -0
- package/libs/darwin-arm64/libXrdCryptossl-6.so +0 -0
- package/libs/darwin-arm64/libXrdSec-6.so +0 -0
- package/libs/darwin-arm64/libXrdSecProt-6.so +0 -0
- package/libs/darwin-arm64/libXrdSeckrb5-6.so +0 -0
- package/libs/darwin-arm64/libXrdSecpwd-6.so +0 -0
- package/libs/darwin-arm64/libXrdSecsss-6.so +0 -0
- package/libs/darwin-arm64/libXrdSecunix-6.so +0 -0
- package/libs/darwin-arm64/libXrdSecztn-6.so +0 -0
- package/libs/darwin-arm64/libXrdUtils.6.dylib +0 -0
- package/libs/darwin-arm64/libXrdXml.6.dylib +0 -0
- package/libs/{libXrdUtils.6.dylib → darwin-x64/libXrdUtils.6.dylib} +0 -0
- package/libs/linux-arm64/libXrdCl.so.6 +0 -0
- package/libs/linux-arm64/libXrdCrypto.so.6 +0 -0
- package/libs/linux-arm64/libXrdCryptossl-6.so +0 -0
- package/libs/linux-arm64/libXrdSec-6.so +0 -0
- package/libs/linux-arm64/libXrdSecProt-6.so +0 -0
- package/libs/linux-arm64/libXrdSeckrb5-6.so +0 -0
- package/libs/linux-arm64/libXrdSecpwd-6.so +0 -0
- package/libs/linux-arm64/libXrdSecsss-6.so +0 -0
- package/libs/linux-arm64/libXrdSecunix-6.so +0 -0
- package/libs/linux-arm64/libXrdSecztn-6.so +0 -0
- package/libs/linux-arm64/libXrdUtils.so.6 +0 -0
- package/libs/linux-arm64/libXrdXml.so.6 +0 -0
- package/libs/{libXrdCrypto.so.6 → linux-x64/libXrdCrypto.so.6} +0 -0
- package/libs/linux-x64/libXrdCryptossl-6.so +0 -0
- package/libs/linux-x64/libXrdSec-6.so +0 -0
- package/libs/linux-x64/libXrdSecProt-6.so +0 -0
- package/libs/linux-x64/libXrdSeckrb5-6.so +0 -0
- package/libs/linux-x64/libXrdSecpwd-6.so +0 -0
- package/libs/linux-x64/libXrdSecsss-6.so +0 -0
- package/libs/linux-x64/libXrdSecunix-6.so +0 -0
- package/libs/linux-x64/libXrdSecztn-6.so +0 -0
- package/libs/{libXrdUtils.so.6 → linux-x64/libXrdUtils.so.6} +0 -0
- package/libs/{libXrdXml.so.6 → linux-x64/libXrdXml.so.6} +0 -0
- package/package.json +1 -2
- package/prebuilds/darwin-arm64/xrootd.node +0 -0
- package/prebuilds/darwin-x64/xrootd.node +0 -0
- package/prebuilds/linux-arm64/xrootd.node +0 -0
- package/prebuilds/linux-x64/xrootd.node +0 -0
- package/prebuilds/xrootd.node +0 -0
- /package/libs/{libXrdCl.6.dylib → darwin-x64/libXrdCl.6.dylib} +0 -0
- /package/libs/{libXrdCrypto.6.dylib → darwin-x64/libXrdCrypto.6.dylib} +0 -0
- /package/libs/{libXrdCryptossl-6.so → darwin-x64/libXrdCryptossl-6.so} +0 -0
- /package/libs/{libXrdSec-6.so → darwin-x64/libXrdSec-6.so} +0 -0
- /package/libs/{libXrdSecProt-6.so → darwin-x64/libXrdSecProt-6.so} +0 -0
- /package/libs/{libXrdSeckrb5-6.so → darwin-x64/libXrdSeckrb5-6.so} +0 -0
- /package/libs/{libXrdSecpwd-6.so → darwin-x64/libXrdSecpwd-6.so} +0 -0
- /package/libs/{libXrdSecsss-6.so → darwin-x64/libXrdSecsss-6.so} +0 -0
- /package/libs/{libXrdSecunix-6.so → darwin-x64/libXrdSecunix-6.so} +0 -0
- /package/libs/{libXrdSecztn-6.so → darwin-x64/libXrdSecztn-6.so} +0 -0
- /package/libs/{libXrdXml.6.dylib → darwin-x64/libXrdXml.6.dylib} +0 -0
- /package/libs/{libXrdCl.so.6 → linux-x64/libXrdCl.so.6} +0 -0
package/README.md
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
> [!WARNING]
|
|
4
4
|
> **Working in process**. This package is currently under active development and not ready for production use. Stay tuned!
|
|
5
5
|
|
|
6
|
-
- now complete: FileSystem/Url/Env
|
|
7
|
-
- in progress:
|
|
6
|
+
- now complete: FileSystem/Url/Env/File
|
|
7
|
+
- in progress: CopyProcess/ErrorProcess/And others
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
package/dist/index.cjs
CHANGED
|
@@ -144,13 +144,20 @@ var File = class {
|
|
|
144
144
|
async read(offset, size) {
|
|
145
145
|
return this._internal.Read(BigInt(offset), size);
|
|
146
146
|
}
|
|
147
|
+
async write(offset, arg1, arg2, arg3) {
|
|
148
|
+
if (Buffer.isBuffer(arg1)) return this._internal.Write(BigInt(offset), arg1);
|
|
149
|
+
else if (typeof arg1 === "number" && typeof arg2 === "number") return this._internal.WriteFd(BigInt(offset), arg1, arg2, arg3 !== void 0 ? BigInt(arg3) : void 0);
|
|
150
|
+
else throw new TypeError("Invalid arguments for write");
|
|
151
|
+
}
|
|
147
152
|
/**
|
|
148
|
-
* 写入文件块
|
|
149
|
-
* @param offset
|
|
150
|
-
* @param
|
|
153
|
+
* 从本地 fd 写入文件块 (直接映射)
|
|
154
|
+
* @param offset 写入的起始字节偏移量。
|
|
155
|
+
* @param size 写入大小。
|
|
156
|
+
* @param fd 本地文件描述符 (fd)。
|
|
157
|
+
* @param fdoff 可选,从本地 fd 中读取的起始偏移。
|
|
151
158
|
*/
|
|
152
|
-
async
|
|
153
|
-
return this._internal.
|
|
159
|
+
async writeFd(offset, size, fd, fdoff) {
|
|
160
|
+
return this._internal.WriteFd(BigInt(offset), size, fd, fdoff !== void 0 ? BigInt(fdoff) : void 0);
|
|
154
161
|
}
|
|
155
162
|
/**
|
|
156
163
|
* 同步文件缓冲区到磁盘
|
|
@@ -656,12 +663,88 @@ var XRootDUrl = class XRootDUrl {
|
|
|
656
663
|
};
|
|
657
664
|
//#endregion
|
|
658
665
|
//#region lib/env.ts
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
666
|
+
function checkIntRange(key, value) {
|
|
667
|
+
const num = Number(value);
|
|
668
|
+
if (num < -2147483648 || num > 2147483647) console.warn(`[xrootd] Warning: value ${value} for key "${key}" is out of 32-bit signed integer range [-2147483648, 2147483647]. It will be truncated.`);
|
|
669
|
+
}
|
|
670
|
+
var XRootDEnvironment = class {
|
|
671
|
+
constructor() {}
|
|
672
|
+
/**
|
|
673
|
+
* 设置整数配置项,返回是否设置成功。
|
|
674
|
+
*/
|
|
675
|
+
putInt(key, intVal) {
|
|
676
|
+
checkIntRange(key, intVal);
|
|
677
|
+
const success = nativeAddon.Env.PutInt(key, Number(intVal));
|
|
678
|
+
if (!success) console.warn(`[xrootd] Warning: Failed to set integer configuration "${key}"=${intVal}. It might have been overridden by a system environment variable.`);
|
|
679
|
+
return success;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* 设置字符串配置项,返回是否设置成功。
|
|
683
|
+
*/
|
|
684
|
+
putString(key, strVal) {
|
|
685
|
+
if (key === "SecProtocol") {
|
|
686
|
+
process.env.XrdSecPROTOCOL = strVal;
|
|
687
|
+
process.env.XRD_SECPROTOCOL = strVal;
|
|
688
|
+
return true;
|
|
689
|
+
}
|
|
690
|
+
const success = nativeAddon.Env.PutString(key, strVal);
|
|
691
|
+
if (!success) console.warn(`[xrootd] Warning: Failed to set string configuration "${key}"="${strVal}". It might have been overridden by a system environment variable.`);
|
|
692
|
+
return success;
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* 设置布尔配置项,返回是否设置成功。
|
|
696
|
+
*/
|
|
697
|
+
putBoolean(key, boolVal) {
|
|
698
|
+
if (typeof boolVal === "boolean") boolVal = boolVal ? "true" : "false";
|
|
699
|
+
return this.putString(key, boolVal);
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* 获取整数配置项。
|
|
703
|
+
*/
|
|
704
|
+
getInt(key) {
|
|
705
|
+
return nativeAddon.Env.GetInt(key) ?? void 0;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* 获取字符串配置项。
|
|
709
|
+
*/
|
|
710
|
+
getString(key) {
|
|
711
|
+
if (key === "SecProtocol") return process.env.XrdSecPROTOCOL ?? process.env.XRD_SECPROTOCOL ?? void 0;
|
|
712
|
+
return nativeAddon.Env.GetString(key) ?? void 0;
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* 批量安全地设置 XRootD 底层参数
|
|
716
|
+
*/
|
|
717
|
+
configure(config) {
|
|
718
|
+
for (const [key, value] of Object.entries(config)) {
|
|
719
|
+
if (value === void 0 || value === null) continue;
|
|
720
|
+
let success = true;
|
|
721
|
+
if (key === "SecProtocol") {
|
|
722
|
+
process.env.XrdSecPROTOCOL = String(value);
|
|
723
|
+
process.env.XRD_SECPROTOCOL = String(value);
|
|
724
|
+
continue;
|
|
725
|
+
}
|
|
726
|
+
if (typeof value === "number" || typeof value === "bigint") {
|
|
727
|
+
checkIntRange(key, value);
|
|
728
|
+
success = nativeAddon.Env.PutInt(key, Number(value));
|
|
729
|
+
} else if (typeof value === "string") success = nativeAddon.Env.PutString(key, value);
|
|
730
|
+
else if (typeof value === "boolean") success = nativeAddon.Env.PutString(key, value ? "true" : "false");
|
|
731
|
+
else {
|
|
732
|
+
console.warn(`[xrootd] Unhandled type ${typeof value} for key ${key}.`);
|
|
733
|
+
success = nativeAddon.Env.PutString(key, value.toString());
|
|
734
|
+
}
|
|
735
|
+
if (!success) console.warn(`[xrootd] Warning: Failed to set configuration "${key}"=${value}. It might have been overridden by a system environment variable.`);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
get(key) {
|
|
739
|
+
if (key === "SecProtocol") return process.env.XrdSecPROTOCOL ?? process.env.XRD_SECPROTOCOL ?? void 0;
|
|
740
|
+
return nativeAddon.Env.GetInt(key) ?? nativeAddon.Env.GetString(key) ?? void 0;
|
|
741
|
+
}
|
|
664
742
|
};
|
|
743
|
+
const Env = new XRootDEnvironment();
|
|
744
|
+
Env.configure({
|
|
745
|
+
RequestTimeout: 30,
|
|
746
|
+
WorkerThreads: 4
|
|
747
|
+
});
|
|
665
748
|
//#endregion
|
|
666
749
|
exports.AccessMode = AccessMode;
|
|
667
750
|
exports.Env = Env;
|
package/dist/index.d.cts
CHANGED
|
@@ -76,6 +76,7 @@ interface INativeFile {
|
|
|
76
76
|
Stat(): Promise<StatInfo>;
|
|
77
77
|
Read(offset: bigint, size: number): Promise<Buffer>;
|
|
78
78
|
Write(offset: bigint, buffer: Buffer): Promise<void>;
|
|
79
|
+
WriteFd(offset: bigint, size: number, fd: number, fdoff?: bigint): Promise<void>;
|
|
79
80
|
Sync(): Promise<void>;
|
|
80
81
|
Truncate(size: bigint): Promise<void>;
|
|
81
82
|
IsOpen(): boolean;
|
|
@@ -196,11 +197,27 @@ declare class File$1 {
|
|
|
196
197
|
*/
|
|
197
198
|
read(offset: bigint | number, size: number): Promise<Buffer>;
|
|
198
199
|
/**
|
|
199
|
-
* 写入文件块
|
|
200
|
+
* 写入文件块 (Buffer 写入)
|
|
200
201
|
* @param offset 偏移量
|
|
201
202
|
* @param buffer 要写入的数据
|
|
202
203
|
*/
|
|
203
204
|
write(offset: bigint | number, buffer: Buffer): Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* 从本地 fd 写入文件块
|
|
207
|
+
* @param offset 写入的起始字节偏移量。
|
|
208
|
+
* @param size 写入大小。
|
|
209
|
+
* @param fd 本地文件描述符 (fd)。
|
|
210
|
+
* @param fdoff 可选,从本地 fd 中读取的起始偏移。
|
|
211
|
+
*/
|
|
212
|
+
write(offset: bigint | number, size: number, fd: number, fdoff?: bigint | number): Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* 从本地 fd 写入文件块 (直接映射)
|
|
215
|
+
* @param offset 写入的起始字节偏移量。
|
|
216
|
+
* @param size 写入大小。
|
|
217
|
+
* @param fd 本地文件描述符 (fd)。
|
|
218
|
+
* @param fdoff 可选,从本地 fd 中读取的起始偏移。
|
|
219
|
+
*/
|
|
220
|
+
writeFd(offset: bigint | number, size: number, fd: number, fdoff?: bigint | number): Promise<void>;
|
|
204
221
|
/**
|
|
205
222
|
* 同步文件缓冲区到磁盘
|
|
206
223
|
*/
|
|
@@ -444,11 +461,301 @@ declare class XRootDUrl {
|
|
|
444
461
|
}
|
|
445
462
|
//#endregion
|
|
446
463
|
//#region lib/env.d.ts
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
464
|
+
type String = string;
|
|
465
|
+
type Int = number | bigint;
|
|
466
|
+
type Bool = 'true' | 'false';
|
|
467
|
+
/**
|
|
468
|
+
* XRootD 底层客户端环境变量配置
|
|
469
|
+
* 参考自: XrdClConstants.hh 与 XrdClDefaultEnv.cc
|
|
470
|
+
*/
|
|
471
|
+
interface XRootDEnvConfig {
|
|
472
|
+
/**
|
|
473
|
+
* 每个通道的子流数量,用于多路复用并行传输。默认值: 1
|
|
474
|
+
*/
|
|
475
|
+
SubStreamsPerChannel?: Int;
|
|
476
|
+
/**
|
|
477
|
+
* 默认的请求超时时间 (秒)。
|
|
478
|
+
* 注意: XRootD C++ 默认是 1800(30 分钟),本 Node.js 库初始化时重置为 30。
|
|
479
|
+
*/
|
|
480
|
+
RequestTimeout?: Int;
|
|
481
|
+
/**
|
|
482
|
+
* 连接重试次数。默认值: 5
|
|
483
|
+
*/
|
|
484
|
+
ConnectionRetry?: Int;
|
|
485
|
+
/**
|
|
486
|
+
* 连接窗口时间 (秒)。如果在该窗口内没有成功建立连接,则报错。默认值: 120
|
|
487
|
+
*/
|
|
488
|
+
ConnectionWindow?: Int;
|
|
489
|
+
/**
|
|
490
|
+
* 流超时时间 (秒)。默认值: 60
|
|
491
|
+
*/
|
|
492
|
+
StreamTimeout?: Int;
|
|
493
|
+
/**
|
|
494
|
+
* 超时检测的时间精度/分辨率 (秒)。默认值: 15
|
|
495
|
+
*/
|
|
496
|
+
TimeoutResolution?: Int;
|
|
497
|
+
/**
|
|
498
|
+
* 流错误统计的时间窗口长度 (秒)。默认值: 1800
|
|
499
|
+
*/
|
|
500
|
+
StreamErrorWindow?: Int;
|
|
501
|
+
/**
|
|
502
|
+
* 是否启用多进程 fork 处理器,用于管理多线程 fork 同步。默认值: 1
|
|
503
|
+
*/
|
|
504
|
+
RunForkHandler?: Int;
|
|
505
|
+
/**
|
|
506
|
+
* 重定向的最大限制次数。默认值: 16
|
|
507
|
+
*/
|
|
508
|
+
RedirectLimit?: Int;
|
|
509
|
+
/**
|
|
510
|
+
* 内部工作线程数。默认值: 3。注意:本 Node.js 库初始化时重置为 4。
|
|
511
|
+
*/
|
|
512
|
+
WorkerThreads?: Int;
|
|
513
|
+
/**
|
|
514
|
+
* 并发运行的事件循环数量。默认值: 10
|
|
515
|
+
*/
|
|
516
|
+
ParallelEvtLoop?: Int;
|
|
517
|
+
/**
|
|
518
|
+
* 是否启用 TCP_NODELAY (禁用 Nagle 算法)。默认值: Linux 下为 1,OSX 下为 0
|
|
519
|
+
*/
|
|
520
|
+
NoDelay?: Int;
|
|
521
|
+
/**
|
|
522
|
+
* 异步 I/O 通知使用的信号(0 表示不使用)。默认值: 0
|
|
523
|
+
*/
|
|
524
|
+
AioSignal?: Int;
|
|
525
|
+
/**
|
|
526
|
+
* Copy 复制过程所使用的基本分块大小 (字节)。默认值: 8388608 (8MB)
|
|
527
|
+
*/
|
|
528
|
+
CPChunkSize?: Int;
|
|
529
|
+
/**
|
|
530
|
+
* Copy 过程中同时并发传输的分块数量。默认值: 4
|
|
531
|
+
*/
|
|
532
|
+
CPParallelChunks?: Int;
|
|
533
|
+
/**
|
|
534
|
+
* Copy 任务的初始化阶段超时时间 (秒)。默认值: 600
|
|
535
|
+
*/
|
|
536
|
+
CPInitTimeout?: Int;
|
|
537
|
+
/**
|
|
538
|
+
* 第三方复制 (Third Party Copy, TPC) 过程超时时间 (秒)。默认值: 1800
|
|
539
|
+
*/
|
|
540
|
+
CPTPCTimeout?: Int;
|
|
541
|
+
/**
|
|
542
|
+
* 整个 Copy 复制任务的总体超时时间 (秒,0 表示不限制)。默认值: 0
|
|
543
|
+
*/
|
|
544
|
+
CPTimeout?: Int;
|
|
545
|
+
/**
|
|
546
|
+
* 扩展 Copy 的单次写入最大块大小 (字节)。默认值: 134217728 (128MB)
|
|
547
|
+
*/
|
|
548
|
+
XCpBlockSize?: Int;
|
|
549
|
+
/**
|
|
550
|
+
* 写入被引导至负载均衡器时的重试次数上限。默认值: 3
|
|
551
|
+
*/
|
|
552
|
+
RetryWrtAtLBLimit?: Int;
|
|
553
|
+
/**
|
|
554
|
+
* Copy 任务的重试次数。默认值: 0
|
|
555
|
+
*/
|
|
556
|
+
CpRetry?: Int;
|
|
557
|
+
/**
|
|
558
|
+
* 在 Copy 复制传输时,是否启用渐进式读写。默认值: 1
|
|
559
|
+
*/
|
|
560
|
+
CpUsePgWrtRd?: Int;
|
|
561
|
+
/**
|
|
562
|
+
* 复制文件时是否保留扩展属性 (XAttrs)。默认值: 0
|
|
563
|
+
*/
|
|
564
|
+
PreserveXAttrs?: Int;
|
|
565
|
+
/**
|
|
566
|
+
* Copy 任务失败后的重试策略。默认值: "force"
|
|
567
|
+
*/
|
|
568
|
+
CpRetryPolicy?: 'force' | 'continue';
|
|
569
|
+
/**
|
|
570
|
+
* Copy 操作的目标类型。默认值: ""
|
|
571
|
+
*/
|
|
572
|
+
CpTarget?: String;
|
|
573
|
+
/**
|
|
574
|
+
* 是否启用 TCP Keep-Alive。默认值: 0
|
|
575
|
+
*/
|
|
576
|
+
TCPKeepAlive?: Int;
|
|
577
|
+
/**
|
|
578
|
+
* TCP 空闲多长时间后发送首次 Keep-Alive 探测包 (秒)。默认值: 7200
|
|
579
|
+
*/
|
|
580
|
+
TCPKeepAliveTime?: Int;
|
|
581
|
+
/**
|
|
582
|
+
* 两次 TCP Keep-Alive 探测包 of 发送间隔时间 (秒)。默认值: 75
|
|
583
|
+
*/
|
|
584
|
+
TCPKeepAliveInterval?: Int;
|
|
585
|
+
/**
|
|
586
|
+
* 连接断开前,最大允许的 TCP Keep-Alive 探测未响应次数。默认值: 9
|
|
587
|
+
*/
|
|
588
|
+
TCPKeepAliveProbes?: Int;
|
|
589
|
+
/**
|
|
590
|
+
* 数据服务器连接的生存时间 (TTL,秒)。默认值: 300
|
|
591
|
+
*/
|
|
592
|
+
DataServerTTL?: Int;
|
|
593
|
+
/**
|
|
594
|
+
* 负载均衡器连接的生存时间 (TTL,秒)。默认值: 1200
|
|
595
|
+
*/
|
|
596
|
+
LoadBalancerTTL?: Int;
|
|
597
|
+
/**
|
|
598
|
+
* 解析 IP 后是否禁止打乱顺序 (打乱顺序有利于负载均衡)。默认值: 0
|
|
599
|
+
*/
|
|
600
|
+
IPNoShuffle?: Int;
|
|
601
|
+
/**
|
|
602
|
+
* 定位端点时是否记录并排除已尝试失败的地址。默认值: 1
|
|
603
|
+
*/
|
|
604
|
+
PreserveLocateTried?: Int;
|
|
605
|
+
/**
|
|
606
|
+
* DNS 解析时是否优先选择 IPv4 而非 IPv6。默认值: 0
|
|
607
|
+
*/
|
|
608
|
+
PreferIPv4?: Int;
|
|
609
|
+
/**
|
|
610
|
+
* 首选的 Poller 轮询器实现。默认值: "built-in"
|
|
611
|
+
*/
|
|
612
|
+
PollerPreference?: 'built-in' | (string & {});
|
|
613
|
+
/**
|
|
614
|
+
* 使用的网络协议栈 (如 "IPAuto", "IPv4", "IPv6")。默认值: "IPAuto"
|
|
615
|
+
*/
|
|
616
|
+
NetworkStack?: 'IPAuto' | 'IPv4' | 'IPv6' | 'IPv4Mapped6' | 'IPAll';
|
|
617
|
+
/**
|
|
618
|
+
* 读数据失败时的恢复策略。默认值: "true"
|
|
619
|
+
*/
|
|
620
|
+
ReadRecovery?: Bool;
|
|
621
|
+
/**
|
|
622
|
+
* 写数据失败时的恢复策略。默认值: "true"
|
|
623
|
+
*/
|
|
624
|
+
WriteRecovery?: Bool;
|
|
625
|
+
/**
|
|
626
|
+
* 打开文件失败时的恢复策略。默认值: "true"
|
|
627
|
+
*/
|
|
628
|
+
OpenRecovery?: Bool;
|
|
629
|
+
/**
|
|
630
|
+
* 是否启用 Metalink 解析和处理。默认值: 1
|
|
631
|
+
*/
|
|
632
|
+
MetalinkProcessing?: Int;
|
|
633
|
+
/**
|
|
634
|
+
* 是否允许解析本地存储 of Metalink 文件。默认值: 0
|
|
635
|
+
*/
|
|
636
|
+
LocalMetalinkFile?: Int;
|
|
637
|
+
/**
|
|
638
|
+
* 等待 Metalink 下载的最大时间 (秒)。默认值: 60
|
|
639
|
+
*/
|
|
640
|
+
MaxMetalinkWait?: Int;
|
|
641
|
+
/**
|
|
642
|
+
* 是否对 Zip 文件的 Metalink 执行校验和检查。默认值: 0
|
|
643
|
+
*/
|
|
644
|
+
ZipMtlnCksum?: Int;
|
|
645
|
+
/**
|
|
646
|
+
* 强制使用的安全协议,例如 "unix" 或 "krb5,unix"(底层通过系统环境变量设置)。
|
|
647
|
+
*/
|
|
648
|
+
SecProtocol?: 'unix' | 'sss' | 'krb5' | 'pwd' | 'gsi' | 'host' | 'ztn' | (string & {});
|
|
649
|
+
/**
|
|
650
|
+
* 未授权 (Permission Denied) 时,触发自动刷新证书并重试的次数上限。默认值: 3
|
|
651
|
+
*/
|
|
652
|
+
NotAuthorizedRetryLimit?: Int;
|
|
653
|
+
/**
|
|
654
|
+
* 如果 TLS 握手失败,是否允许降级为非 TLS 明文传输。默认值: 0
|
|
655
|
+
*/
|
|
656
|
+
NoTlsOK?: Int;
|
|
657
|
+
/**
|
|
658
|
+
* 是否只对控制通道加密(控制通道加密,数据通道明文)。默认值: 0
|
|
659
|
+
*/
|
|
660
|
+
TlsNoData?: Int;
|
|
661
|
+
/**
|
|
662
|
+
* 获取 Metalink 配置文件时是否启用 TLS。默认值: 0
|
|
663
|
+
*/
|
|
664
|
+
TlsMetalink?: Int;
|
|
665
|
+
/**
|
|
666
|
+
* 是否在访问非渐进式文件时要求 TLS。默认值: 0
|
|
667
|
+
*/
|
|
668
|
+
WantTlsOnNoPgrw?: Int;
|
|
669
|
+
/**
|
|
670
|
+
* TLS 调试级别(如 "OFF", "INFO", "DEBUG")。默认值: "OFF"
|
|
671
|
+
*/
|
|
672
|
+
TlsDbgLvl?: 'OFF' | 'CTX' | 'SOK' | 'SIO' | 'ALL' | 'OUT' | 'INFO' | 'DEBUG' | (string & {});
|
|
673
|
+
/**
|
|
674
|
+
* 是否启用多协议通道支持。默认值: 0
|
|
675
|
+
*/
|
|
676
|
+
MultiProtocol?: Int;
|
|
677
|
+
/**
|
|
678
|
+
* 日志文件路径。底层拦截设置,直接对 C++ logger 生效。默认值: ""
|
|
679
|
+
*/
|
|
680
|
+
LogFile?: String;
|
|
681
|
+
/**
|
|
682
|
+
* 调试日志级别(如 "Dump", "Debug", "Info", "Warning", "Error", "")。底层拦截设置。
|
|
683
|
+
*/
|
|
684
|
+
DebugLevel?: 'Dump' | 'Debug' | 'Info' | 'Warning' | 'Error' | '';
|
|
685
|
+
/**
|
|
686
|
+
* 日志掩码,指定哪些子系统输出日志。底层拦截设置。
|
|
687
|
+
*/
|
|
688
|
+
LogMask?: String;
|
|
689
|
+
/**
|
|
690
|
+
* 客户端配置文件加载目录。默认值: ""
|
|
691
|
+
*/
|
|
692
|
+
ClConfDir?: String;
|
|
693
|
+
/**
|
|
694
|
+
* 默认客户端配置文件的绝对路径。默认值: ""
|
|
695
|
+
*/
|
|
696
|
+
DefaultClConfFile?: String;
|
|
697
|
+
/**
|
|
698
|
+
* 安全或传输插件配置文件的加载目录。默认值: ""
|
|
699
|
+
*/
|
|
700
|
+
PlugInConfDir?: String;
|
|
701
|
+
/**
|
|
702
|
+
* 指定动态加载的插件名称。默认值: ""
|
|
703
|
+
*/
|
|
704
|
+
PlugIn?: String;
|
|
705
|
+
/**
|
|
706
|
+
* 外部客户端监控插件动态链接库的加载路径。默认值: ""
|
|
707
|
+
*/
|
|
708
|
+
ClientMonitor?: String;
|
|
709
|
+
/**
|
|
710
|
+
* 传递给外部客户端监控插件的参数字符串。默认值: ""
|
|
711
|
+
*/
|
|
712
|
+
ClientMonitorParam?: String;
|
|
713
|
+
/**
|
|
714
|
+
* 应用的标识名称。默认值: 当前可执行文件名
|
|
715
|
+
*/
|
|
716
|
+
AppName?: String;
|
|
717
|
+
/**
|
|
718
|
+
* 监控上报信息内容。默认值: ""
|
|
719
|
+
*/
|
|
720
|
+
MonInfo?: String;
|
|
721
|
+
}
|
|
722
|
+
type KeysOfValue<T, TValue> = { [K in keyof T]: T[K] extends TValue ? K : never }[keyof T];
|
|
723
|
+
type XRootDEnvConfigIntKey = KeysOfValue<Required<XRootDEnvConfig>, Int>;
|
|
724
|
+
type XRootDEnvConfigBoolKey = KeysOfValue<Required<XRootDEnvConfig>, Bool>;
|
|
725
|
+
type XRootDEnvConfigStringKey = KeysOfValue<Required<XRootDEnvConfig>, String>;
|
|
726
|
+
declare class XRootDEnvironment {
|
|
727
|
+
constructor();
|
|
728
|
+
/**
|
|
729
|
+
* 设置整数配置项,返回是否设置成功。
|
|
730
|
+
*/
|
|
731
|
+
putInt(key: XRootDEnvConfigIntKey, intVal: number | bigint): boolean;
|
|
732
|
+
/**
|
|
733
|
+
* 设置字符串配置项,返回是否设置成功。
|
|
734
|
+
*/
|
|
735
|
+
putString(key: XRootDEnvConfigStringKey | XRootDEnvConfigBoolKey, strVal: string): boolean;
|
|
736
|
+
/**
|
|
737
|
+
* 设置布尔配置项,返回是否设置成功。
|
|
738
|
+
*/
|
|
739
|
+
putBoolean(key: XRootDEnvConfigBoolKey, boolVal: boolean | Bool): boolean;
|
|
740
|
+
/**
|
|
741
|
+
* 获取整数配置项。
|
|
742
|
+
*/
|
|
743
|
+
getInt(key: XRootDEnvConfigIntKey): number | undefined;
|
|
744
|
+
/**
|
|
745
|
+
* 获取字符串配置项。
|
|
746
|
+
*/
|
|
747
|
+
getString(key: XRootDEnvConfigStringKey): string | undefined;
|
|
748
|
+
/**
|
|
749
|
+
* 批量安全地设置 XRootD 底层参数
|
|
750
|
+
*/
|
|
751
|
+
configure(config: XRootDEnvConfig): void;
|
|
752
|
+
/**
|
|
753
|
+
* 获取指定配置
|
|
754
|
+
*/
|
|
755
|
+
get(key: XRootDEnvConfigBoolKey): string | undefined;
|
|
756
|
+
get(key: XRootDEnvConfigStringKey): string | undefined;
|
|
757
|
+
get(key: XRootDEnvConfigIntKey): number | undefined;
|
|
758
|
+
}
|
|
759
|
+
declare const Env: XRootDEnvironment;
|
|
453
760
|
//#endregion
|
|
454
761
|
export { AccessMode, Env, File$1 as File, FileSystem, type LocationInfo, MkDirFlags, OpenFlags, type PropertyList, type ReadChunkRequest, type ReadStreamOptions, type StatInfo, type StatVFSInfo, XRootDUrl as URL, type WriteStreamOptions, type XRootDError };
|
package/dist/index.d.mts
CHANGED
|
@@ -76,6 +76,7 @@ interface INativeFile {
|
|
|
76
76
|
Stat(): Promise<StatInfo>;
|
|
77
77
|
Read(offset: bigint, size: number): Promise<Buffer>;
|
|
78
78
|
Write(offset: bigint, buffer: Buffer): Promise<void>;
|
|
79
|
+
WriteFd(offset: bigint, size: number, fd: number, fdoff?: bigint): Promise<void>;
|
|
79
80
|
Sync(): Promise<void>;
|
|
80
81
|
Truncate(size: bigint): Promise<void>;
|
|
81
82
|
IsOpen(): boolean;
|
|
@@ -196,11 +197,27 @@ declare class File$1 {
|
|
|
196
197
|
*/
|
|
197
198
|
read(offset: bigint | number, size: number): Promise<Buffer>;
|
|
198
199
|
/**
|
|
199
|
-
* 写入文件块
|
|
200
|
+
* 写入文件块 (Buffer 写入)
|
|
200
201
|
* @param offset 偏移量
|
|
201
202
|
* @param buffer 要写入的数据
|
|
202
203
|
*/
|
|
203
204
|
write(offset: bigint | number, buffer: Buffer): Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* 从本地 fd 写入文件块
|
|
207
|
+
* @param offset 写入的起始字节偏移量。
|
|
208
|
+
* @param size 写入大小。
|
|
209
|
+
* @param fd 本地文件描述符 (fd)。
|
|
210
|
+
* @param fdoff 可选,从本地 fd 中读取的起始偏移。
|
|
211
|
+
*/
|
|
212
|
+
write(offset: bigint | number, size: number, fd: number, fdoff?: bigint | number): Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* 从本地 fd 写入文件块 (直接映射)
|
|
215
|
+
* @param offset 写入的起始字节偏移量。
|
|
216
|
+
* @param size 写入大小。
|
|
217
|
+
* @param fd 本地文件描述符 (fd)。
|
|
218
|
+
* @param fdoff 可选,从本地 fd 中读取的起始偏移。
|
|
219
|
+
*/
|
|
220
|
+
writeFd(offset: bigint | number, size: number, fd: number, fdoff?: bigint | number): Promise<void>;
|
|
204
221
|
/**
|
|
205
222
|
* 同步文件缓冲区到磁盘
|
|
206
223
|
*/
|
|
@@ -444,11 +461,301 @@ declare class XRootDUrl {
|
|
|
444
461
|
}
|
|
445
462
|
//#endregion
|
|
446
463
|
//#region lib/env.d.ts
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
464
|
+
type String = string;
|
|
465
|
+
type Int = number | bigint;
|
|
466
|
+
type Bool = 'true' | 'false';
|
|
467
|
+
/**
|
|
468
|
+
* XRootD 底层客户端环境变量配置
|
|
469
|
+
* 参考自: XrdClConstants.hh 与 XrdClDefaultEnv.cc
|
|
470
|
+
*/
|
|
471
|
+
interface XRootDEnvConfig {
|
|
472
|
+
/**
|
|
473
|
+
* 每个通道的子流数量,用于多路复用并行传输。默认值: 1
|
|
474
|
+
*/
|
|
475
|
+
SubStreamsPerChannel?: Int;
|
|
476
|
+
/**
|
|
477
|
+
* 默认的请求超时时间 (秒)。
|
|
478
|
+
* 注意: XRootD C++ 默认是 1800(30 分钟),本 Node.js 库初始化时重置为 30。
|
|
479
|
+
*/
|
|
480
|
+
RequestTimeout?: Int;
|
|
481
|
+
/**
|
|
482
|
+
* 连接重试次数。默认值: 5
|
|
483
|
+
*/
|
|
484
|
+
ConnectionRetry?: Int;
|
|
485
|
+
/**
|
|
486
|
+
* 连接窗口时间 (秒)。如果在该窗口内没有成功建立连接,则报错。默认值: 120
|
|
487
|
+
*/
|
|
488
|
+
ConnectionWindow?: Int;
|
|
489
|
+
/**
|
|
490
|
+
* 流超时时间 (秒)。默认值: 60
|
|
491
|
+
*/
|
|
492
|
+
StreamTimeout?: Int;
|
|
493
|
+
/**
|
|
494
|
+
* 超时检测的时间精度/分辨率 (秒)。默认值: 15
|
|
495
|
+
*/
|
|
496
|
+
TimeoutResolution?: Int;
|
|
497
|
+
/**
|
|
498
|
+
* 流错误统计的时间窗口长度 (秒)。默认值: 1800
|
|
499
|
+
*/
|
|
500
|
+
StreamErrorWindow?: Int;
|
|
501
|
+
/**
|
|
502
|
+
* 是否启用多进程 fork 处理器,用于管理多线程 fork 同步。默认值: 1
|
|
503
|
+
*/
|
|
504
|
+
RunForkHandler?: Int;
|
|
505
|
+
/**
|
|
506
|
+
* 重定向的最大限制次数。默认值: 16
|
|
507
|
+
*/
|
|
508
|
+
RedirectLimit?: Int;
|
|
509
|
+
/**
|
|
510
|
+
* 内部工作线程数。默认值: 3。注意:本 Node.js 库初始化时重置为 4。
|
|
511
|
+
*/
|
|
512
|
+
WorkerThreads?: Int;
|
|
513
|
+
/**
|
|
514
|
+
* 并发运行的事件循环数量。默认值: 10
|
|
515
|
+
*/
|
|
516
|
+
ParallelEvtLoop?: Int;
|
|
517
|
+
/**
|
|
518
|
+
* 是否启用 TCP_NODELAY (禁用 Nagle 算法)。默认值: Linux 下为 1,OSX 下为 0
|
|
519
|
+
*/
|
|
520
|
+
NoDelay?: Int;
|
|
521
|
+
/**
|
|
522
|
+
* 异步 I/O 通知使用的信号(0 表示不使用)。默认值: 0
|
|
523
|
+
*/
|
|
524
|
+
AioSignal?: Int;
|
|
525
|
+
/**
|
|
526
|
+
* Copy 复制过程所使用的基本分块大小 (字节)。默认值: 8388608 (8MB)
|
|
527
|
+
*/
|
|
528
|
+
CPChunkSize?: Int;
|
|
529
|
+
/**
|
|
530
|
+
* Copy 过程中同时并发传输的分块数量。默认值: 4
|
|
531
|
+
*/
|
|
532
|
+
CPParallelChunks?: Int;
|
|
533
|
+
/**
|
|
534
|
+
* Copy 任务的初始化阶段超时时间 (秒)。默认值: 600
|
|
535
|
+
*/
|
|
536
|
+
CPInitTimeout?: Int;
|
|
537
|
+
/**
|
|
538
|
+
* 第三方复制 (Third Party Copy, TPC) 过程超时时间 (秒)。默认值: 1800
|
|
539
|
+
*/
|
|
540
|
+
CPTPCTimeout?: Int;
|
|
541
|
+
/**
|
|
542
|
+
* 整个 Copy 复制任务的总体超时时间 (秒,0 表示不限制)。默认值: 0
|
|
543
|
+
*/
|
|
544
|
+
CPTimeout?: Int;
|
|
545
|
+
/**
|
|
546
|
+
* 扩展 Copy 的单次写入最大块大小 (字节)。默认值: 134217728 (128MB)
|
|
547
|
+
*/
|
|
548
|
+
XCpBlockSize?: Int;
|
|
549
|
+
/**
|
|
550
|
+
* 写入被引导至负载均衡器时的重试次数上限。默认值: 3
|
|
551
|
+
*/
|
|
552
|
+
RetryWrtAtLBLimit?: Int;
|
|
553
|
+
/**
|
|
554
|
+
* Copy 任务的重试次数。默认值: 0
|
|
555
|
+
*/
|
|
556
|
+
CpRetry?: Int;
|
|
557
|
+
/**
|
|
558
|
+
* 在 Copy 复制传输时,是否启用渐进式读写。默认值: 1
|
|
559
|
+
*/
|
|
560
|
+
CpUsePgWrtRd?: Int;
|
|
561
|
+
/**
|
|
562
|
+
* 复制文件时是否保留扩展属性 (XAttrs)。默认值: 0
|
|
563
|
+
*/
|
|
564
|
+
PreserveXAttrs?: Int;
|
|
565
|
+
/**
|
|
566
|
+
* Copy 任务失败后的重试策略。默认值: "force"
|
|
567
|
+
*/
|
|
568
|
+
CpRetryPolicy?: 'force' | 'continue';
|
|
569
|
+
/**
|
|
570
|
+
* Copy 操作的目标类型。默认值: ""
|
|
571
|
+
*/
|
|
572
|
+
CpTarget?: String;
|
|
573
|
+
/**
|
|
574
|
+
* 是否启用 TCP Keep-Alive。默认值: 0
|
|
575
|
+
*/
|
|
576
|
+
TCPKeepAlive?: Int;
|
|
577
|
+
/**
|
|
578
|
+
* TCP 空闲多长时间后发送首次 Keep-Alive 探测包 (秒)。默认值: 7200
|
|
579
|
+
*/
|
|
580
|
+
TCPKeepAliveTime?: Int;
|
|
581
|
+
/**
|
|
582
|
+
* 两次 TCP Keep-Alive 探测包 of 发送间隔时间 (秒)。默认值: 75
|
|
583
|
+
*/
|
|
584
|
+
TCPKeepAliveInterval?: Int;
|
|
585
|
+
/**
|
|
586
|
+
* 连接断开前,最大允许的 TCP Keep-Alive 探测未响应次数。默认值: 9
|
|
587
|
+
*/
|
|
588
|
+
TCPKeepAliveProbes?: Int;
|
|
589
|
+
/**
|
|
590
|
+
* 数据服务器连接的生存时间 (TTL,秒)。默认值: 300
|
|
591
|
+
*/
|
|
592
|
+
DataServerTTL?: Int;
|
|
593
|
+
/**
|
|
594
|
+
* 负载均衡器连接的生存时间 (TTL,秒)。默认值: 1200
|
|
595
|
+
*/
|
|
596
|
+
LoadBalancerTTL?: Int;
|
|
597
|
+
/**
|
|
598
|
+
* 解析 IP 后是否禁止打乱顺序 (打乱顺序有利于负载均衡)。默认值: 0
|
|
599
|
+
*/
|
|
600
|
+
IPNoShuffle?: Int;
|
|
601
|
+
/**
|
|
602
|
+
* 定位端点时是否记录并排除已尝试失败的地址。默认值: 1
|
|
603
|
+
*/
|
|
604
|
+
PreserveLocateTried?: Int;
|
|
605
|
+
/**
|
|
606
|
+
* DNS 解析时是否优先选择 IPv4 而非 IPv6。默认值: 0
|
|
607
|
+
*/
|
|
608
|
+
PreferIPv4?: Int;
|
|
609
|
+
/**
|
|
610
|
+
* 首选的 Poller 轮询器实现。默认值: "built-in"
|
|
611
|
+
*/
|
|
612
|
+
PollerPreference?: 'built-in' | (string & {});
|
|
613
|
+
/**
|
|
614
|
+
* 使用的网络协议栈 (如 "IPAuto", "IPv4", "IPv6")。默认值: "IPAuto"
|
|
615
|
+
*/
|
|
616
|
+
NetworkStack?: 'IPAuto' | 'IPv4' | 'IPv6' | 'IPv4Mapped6' | 'IPAll';
|
|
617
|
+
/**
|
|
618
|
+
* 读数据失败时的恢复策略。默认值: "true"
|
|
619
|
+
*/
|
|
620
|
+
ReadRecovery?: Bool;
|
|
621
|
+
/**
|
|
622
|
+
* 写数据失败时的恢复策略。默认值: "true"
|
|
623
|
+
*/
|
|
624
|
+
WriteRecovery?: Bool;
|
|
625
|
+
/**
|
|
626
|
+
* 打开文件失败时的恢复策略。默认值: "true"
|
|
627
|
+
*/
|
|
628
|
+
OpenRecovery?: Bool;
|
|
629
|
+
/**
|
|
630
|
+
* 是否启用 Metalink 解析和处理。默认值: 1
|
|
631
|
+
*/
|
|
632
|
+
MetalinkProcessing?: Int;
|
|
633
|
+
/**
|
|
634
|
+
* 是否允许解析本地存储 of Metalink 文件。默认值: 0
|
|
635
|
+
*/
|
|
636
|
+
LocalMetalinkFile?: Int;
|
|
637
|
+
/**
|
|
638
|
+
* 等待 Metalink 下载的最大时间 (秒)。默认值: 60
|
|
639
|
+
*/
|
|
640
|
+
MaxMetalinkWait?: Int;
|
|
641
|
+
/**
|
|
642
|
+
* 是否对 Zip 文件的 Metalink 执行校验和检查。默认值: 0
|
|
643
|
+
*/
|
|
644
|
+
ZipMtlnCksum?: Int;
|
|
645
|
+
/**
|
|
646
|
+
* 强制使用的安全协议,例如 "unix" 或 "krb5,unix"(底层通过系统环境变量设置)。
|
|
647
|
+
*/
|
|
648
|
+
SecProtocol?: 'unix' | 'sss' | 'krb5' | 'pwd' | 'gsi' | 'host' | 'ztn' | (string & {});
|
|
649
|
+
/**
|
|
650
|
+
* 未授权 (Permission Denied) 时,触发自动刷新证书并重试的次数上限。默认值: 3
|
|
651
|
+
*/
|
|
652
|
+
NotAuthorizedRetryLimit?: Int;
|
|
653
|
+
/**
|
|
654
|
+
* 如果 TLS 握手失败,是否允许降级为非 TLS 明文传输。默认值: 0
|
|
655
|
+
*/
|
|
656
|
+
NoTlsOK?: Int;
|
|
657
|
+
/**
|
|
658
|
+
* 是否只对控制通道加密(控制通道加密,数据通道明文)。默认值: 0
|
|
659
|
+
*/
|
|
660
|
+
TlsNoData?: Int;
|
|
661
|
+
/**
|
|
662
|
+
* 获取 Metalink 配置文件时是否启用 TLS。默认值: 0
|
|
663
|
+
*/
|
|
664
|
+
TlsMetalink?: Int;
|
|
665
|
+
/**
|
|
666
|
+
* 是否在访问非渐进式文件时要求 TLS。默认值: 0
|
|
667
|
+
*/
|
|
668
|
+
WantTlsOnNoPgrw?: Int;
|
|
669
|
+
/**
|
|
670
|
+
* TLS 调试级别(如 "OFF", "INFO", "DEBUG")。默认值: "OFF"
|
|
671
|
+
*/
|
|
672
|
+
TlsDbgLvl?: 'OFF' | 'CTX' | 'SOK' | 'SIO' | 'ALL' | 'OUT' | 'INFO' | 'DEBUG' | (string & {});
|
|
673
|
+
/**
|
|
674
|
+
* 是否启用多协议通道支持。默认值: 0
|
|
675
|
+
*/
|
|
676
|
+
MultiProtocol?: Int;
|
|
677
|
+
/**
|
|
678
|
+
* 日志文件路径。底层拦截设置,直接对 C++ logger 生效。默认值: ""
|
|
679
|
+
*/
|
|
680
|
+
LogFile?: String;
|
|
681
|
+
/**
|
|
682
|
+
* 调试日志级别(如 "Dump", "Debug", "Info", "Warning", "Error", "")。底层拦截设置。
|
|
683
|
+
*/
|
|
684
|
+
DebugLevel?: 'Dump' | 'Debug' | 'Info' | 'Warning' | 'Error' | '';
|
|
685
|
+
/**
|
|
686
|
+
* 日志掩码,指定哪些子系统输出日志。底层拦截设置。
|
|
687
|
+
*/
|
|
688
|
+
LogMask?: String;
|
|
689
|
+
/**
|
|
690
|
+
* 客户端配置文件加载目录。默认值: ""
|
|
691
|
+
*/
|
|
692
|
+
ClConfDir?: String;
|
|
693
|
+
/**
|
|
694
|
+
* 默认客户端配置文件的绝对路径。默认值: ""
|
|
695
|
+
*/
|
|
696
|
+
DefaultClConfFile?: String;
|
|
697
|
+
/**
|
|
698
|
+
* 安全或传输插件配置文件的加载目录。默认值: ""
|
|
699
|
+
*/
|
|
700
|
+
PlugInConfDir?: String;
|
|
701
|
+
/**
|
|
702
|
+
* 指定动态加载的插件名称。默认值: ""
|
|
703
|
+
*/
|
|
704
|
+
PlugIn?: String;
|
|
705
|
+
/**
|
|
706
|
+
* 外部客户端监控插件动态链接库的加载路径。默认值: ""
|
|
707
|
+
*/
|
|
708
|
+
ClientMonitor?: String;
|
|
709
|
+
/**
|
|
710
|
+
* 传递给外部客户端监控插件的参数字符串。默认值: ""
|
|
711
|
+
*/
|
|
712
|
+
ClientMonitorParam?: String;
|
|
713
|
+
/**
|
|
714
|
+
* 应用的标识名称。默认值: 当前可执行文件名
|
|
715
|
+
*/
|
|
716
|
+
AppName?: String;
|
|
717
|
+
/**
|
|
718
|
+
* 监控上报信息内容。默认值: ""
|
|
719
|
+
*/
|
|
720
|
+
MonInfo?: String;
|
|
721
|
+
}
|
|
722
|
+
type KeysOfValue<T, TValue> = { [K in keyof T]: T[K] extends TValue ? K : never }[keyof T];
|
|
723
|
+
type XRootDEnvConfigIntKey = KeysOfValue<Required<XRootDEnvConfig>, Int>;
|
|
724
|
+
type XRootDEnvConfigBoolKey = KeysOfValue<Required<XRootDEnvConfig>, Bool>;
|
|
725
|
+
type XRootDEnvConfigStringKey = KeysOfValue<Required<XRootDEnvConfig>, String>;
|
|
726
|
+
declare class XRootDEnvironment {
|
|
727
|
+
constructor();
|
|
728
|
+
/**
|
|
729
|
+
* 设置整数配置项,返回是否设置成功。
|
|
730
|
+
*/
|
|
731
|
+
putInt(key: XRootDEnvConfigIntKey, intVal: number | bigint): boolean;
|
|
732
|
+
/**
|
|
733
|
+
* 设置字符串配置项,返回是否设置成功。
|
|
734
|
+
*/
|
|
735
|
+
putString(key: XRootDEnvConfigStringKey | XRootDEnvConfigBoolKey, strVal: string): boolean;
|
|
736
|
+
/**
|
|
737
|
+
* 设置布尔配置项,返回是否设置成功。
|
|
738
|
+
*/
|
|
739
|
+
putBoolean(key: XRootDEnvConfigBoolKey, boolVal: boolean | Bool): boolean;
|
|
740
|
+
/**
|
|
741
|
+
* 获取整数配置项。
|
|
742
|
+
*/
|
|
743
|
+
getInt(key: XRootDEnvConfigIntKey): number | undefined;
|
|
744
|
+
/**
|
|
745
|
+
* 获取字符串配置项。
|
|
746
|
+
*/
|
|
747
|
+
getString(key: XRootDEnvConfigStringKey): string | undefined;
|
|
748
|
+
/**
|
|
749
|
+
* 批量安全地设置 XRootD 底层参数
|
|
750
|
+
*/
|
|
751
|
+
configure(config: XRootDEnvConfig): void;
|
|
752
|
+
/**
|
|
753
|
+
* 获取指定配置
|
|
754
|
+
*/
|
|
755
|
+
get(key: XRootDEnvConfigBoolKey): string | undefined;
|
|
756
|
+
get(key: XRootDEnvConfigStringKey): string | undefined;
|
|
757
|
+
get(key: XRootDEnvConfigIntKey): number | undefined;
|
|
758
|
+
}
|
|
759
|
+
declare const Env: XRootDEnvironment;
|
|
453
760
|
//#endregion
|
|
454
761
|
export { AccessMode, Env, File$1 as File, FileSystem, type LocationInfo, MkDirFlags, OpenFlags, type PropertyList, type ReadChunkRequest, type ReadStreamOptions, type StatInfo, type StatVFSInfo, XRootDUrl as URL, type WriteStreamOptions, type XRootDError };
|
package/dist/index.mjs
CHANGED
|
@@ -119,13 +119,20 @@ var File = class {
|
|
|
119
119
|
async read(offset, size) {
|
|
120
120
|
return this._internal.Read(BigInt(offset), size);
|
|
121
121
|
}
|
|
122
|
+
async write(offset, arg1, arg2, arg3) {
|
|
123
|
+
if (Buffer.isBuffer(arg1)) return this._internal.Write(BigInt(offset), arg1);
|
|
124
|
+
else if (typeof arg1 === "number" && typeof arg2 === "number") return this._internal.WriteFd(BigInt(offset), arg1, arg2, arg3 !== void 0 ? BigInt(arg3) : void 0);
|
|
125
|
+
else throw new TypeError("Invalid arguments for write");
|
|
126
|
+
}
|
|
122
127
|
/**
|
|
123
|
-
* 写入文件块
|
|
124
|
-
* @param offset
|
|
125
|
-
* @param
|
|
128
|
+
* 从本地 fd 写入文件块 (直接映射)
|
|
129
|
+
* @param offset 写入的起始字节偏移量。
|
|
130
|
+
* @param size 写入大小。
|
|
131
|
+
* @param fd 本地文件描述符 (fd)。
|
|
132
|
+
* @param fdoff 可选,从本地 fd 中读取的起始偏移。
|
|
126
133
|
*/
|
|
127
|
-
async
|
|
128
|
-
return this._internal.
|
|
134
|
+
async writeFd(offset, size, fd, fdoff) {
|
|
135
|
+
return this._internal.WriteFd(BigInt(offset), size, fd, fdoff !== void 0 ? BigInt(fdoff) : void 0);
|
|
129
136
|
}
|
|
130
137
|
/**
|
|
131
138
|
* 同步文件缓冲区到磁盘
|
|
@@ -631,11 +638,87 @@ var XRootDUrl = class XRootDUrl {
|
|
|
631
638
|
};
|
|
632
639
|
//#endregion
|
|
633
640
|
//#region lib/env.ts
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
641
|
+
function checkIntRange(key, value) {
|
|
642
|
+
const num = Number(value);
|
|
643
|
+
if (num < -2147483648 || num > 2147483647) console.warn(`[xrootd] Warning: value ${value} for key "${key}" is out of 32-bit signed integer range [-2147483648, 2147483647]. It will be truncated.`);
|
|
644
|
+
}
|
|
645
|
+
var XRootDEnvironment = class {
|
|
646
|
+
constructor() {}
|
|
647
|
+
/**
|
|
648
|
+
* 设置整数配置项,返回是否设置成功。
|
|
649
|
+
*/
|
|
650
|
+
putInt(key, intVal) {
|
|
651
|
+
checkIntRange(key, intVal);
|
|
652
|
+
const success = nativeAddon.Env.PutInt(key, Number(intVal));
|
|
653
|
+
if (!success) console.warn(`[xrootd] Warning: Failed to set integer configuration "${key}"=${intVal}. It might have been overridden by a system environment variable.`);
|
|
654
|
+
return success;
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* 设置字符串配置项,返回是否设置成功。
|
|
658
|
+
*/
|
|
659
|
+
putString(key, strVal) {
|
|
660
|
+
if (key === "SecProtocol") {
|
|
661
|
+
process.env.XrdSecPROTOCOL = strVal;
|
|
662
|
+
process.env.XRD_SECPROTOCOL = strVal;
|
|
663
|
+
return true;
|
|
664
|
+
}
|
|
665
|
+
const success = nativeAddon.Env.PutString(key, strVal);
|
|
666
|
+
if (!success) console.warn(`[xrootd] Warning: Failed to set string configuration "${key}"="${strVal}". It might have been overridden by a system environment variable.`);
|
|
667
|
+
return success;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* 设置布尔配置项,返回是否设置成功。
|
|
671
|
+
*/
|
|
672
|
+
putBoolean(key, boolVal) {
|
|
673
|
+
if (typeof boolVal === "boolean") boolVal = boolVal ? "true" : "false";
|
|
674
|
+
return this.putString(key, boolVal);
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* 获取整数配置项。
|
|
678
|
+
*/
|
|
679
|
+
getInt(key) {
|
|
680
|
+
return nativeAddon.Env.GetInt(key) ?? void 0;
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* 获取字符串配置项。
|
|
684
|
+
*/
|
|
685
|
+
getString(key) {
|
|
686
|
+
if (key === "SecProtocol") return process.env.XrdSecPROTOCOL ?? process.env.XRD_SECPROTOCOL ?? void 0;
|
|
687
|
+
return nativeAddon.Env.GetString(key) ?? void 0;
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* 批量安全地设置 XRootD 底层参数
|
|
691
|
+
*/
|
|
692
|
+
configure(config) {
|
|
693
|
+
for (const [key, value] of Object.entries(config)) {
|
|
694
|
+
if (value === void 0 || value === null) continue;
|
|
695
|
+
let success = true;
|
|
696
|
+
if (key === "SecProtocol") {
|
|
697
|
+
process.env.XrdSecPROTOCOL = String(value);
|
|
698
|
+
process.env.XRD_SECPROTOCOL = String(value);
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
701
|
+
if (typeof value === "number" || typeof value === "bigint") {
|
|
702
|
+
checkIntRange(key, value);
|
|
703
|
+
success = nativeAddon.Env.PutInt(key, Number(value));
|
|
704
|
+
} else if (typeof value === "string") success = nativeAddon.Env.PutString(key, value);
|
|
705
|
+
else if (typeof value === "boolean") success = nativeAddon.Env.PutString(key, value ? "true" : "false");
|
|
706
|
+
else {
|
|
707
|
+
console.warn(`[xrootd] Unhandled type ${typeof value} for key ${key}.`);
|
|
708
|
+
success = nativeAddon.Env.PutString(key, value.toString());
|
|
709
|
+
}
|
|
710
|
+
if (!success) console.warn(`[xrootd] Warning: Failed to set configuration "${key}"=${value}. It might have been overridden by a system environment variable.`);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
get(key) {
|
|
714
|
+
if (key === "SecProtocol") return process.env.XrdSecPROTOCOL ?? process.env.XRD_SECPROTOCOL ?? void 0;
|
|
715
|
+
return nativeAddon.Env.GetInt(key) ?? nativeAddon.Env.GetString(key) ?? void 0;
|
|
716
|
+
}
|
|
639
717
|
};
|
|
718
|
+
const Env = new XRootDEnvironment();
|
|
719
|
+
Env.configure({
|
|
720
|
+
RequestTimeout: 30,
|
|
721
|
+
WorkerThreads: 4
|
|
722
|
+
});
|
|
640
723
|
//#endregion
|
|
641
724
|
export { AccessMode, Env, File, FileSystem, MkDirFlags, OpenFlags, XRootDUrl as URL };
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xrootd",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "Prebuilt Node.js Native Addon for XRootD, allowing JS access to EOS file systems",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -70,7 +70,6 @@
|
|
|
70
70
|
],
|
|
71
71
|
"gypfile": false,
|
|
72
72
|
"scripts": {
|
|
73
|
-
"install": "echo 'Skip implicit node-gyp rebuild. Handled by explicit build.'",
|
|
74
73
|
"build:tsc": "tsc --noEmit",
|
|
75
74
|
"build:ts": "tsdown",
|
|
76
75
|
"build:addon": "node-gyp rebuild",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/prebuilds/xrootd.node
DELETED
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|