feat(hosts): connect to saved hosts through a daemon

This commit is contained in:
Mohamed Boudra
2026-10-21 10:33:11 +02:00
parent 5d70bf0645
commit 3b50636e14
39 changed files with 3623 additions and 370 deletions
+22
View File
@@ -0,0 +1,22 @@
/** Counts bytes until the socket's send callback, shared by all links owned by a daemon. */
export class HostTransportBudget {
private used = 0;
constructor(readonly limit = 64 * 1024 * 1024) {}
get bufferedBytes(): number {
return this.used;
}
reserve(bytes: number): () => void {
if (bytes > this.limit - this.used)
throw Object.assign(new Error("Connected host buffer limit reached"), {
code: "resource_limit",
});
this.used += bytes;
let released = false;
return () => {
if (!released) {
released = true;
this.used -= bytes;
}
};
}
}