mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 20:09:04 +00:00
implement node:cluster (#11492)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: nektro <nektro@users.noreply.github.com> Co-authored-by: cirospaciari <ciro.spaciari@gmail.com>
This commit is contained in:
39
src/bun.js/node/node_http_binding.zig
Normal file
39
src/bun.js/node/node_http_binding.zig
Normal file
@@ -0,0 +1,39 @@
|
||||
const std = @import("std");
|
||||
const bun = @import("root").bun;
|
||||
const Environment = bun.Environment;
|
||||
const JSC = bun.JSC;
|
||||
const string = bun.string;
|
||||
const Output = bun.Output;
|
||||
const ZigString = JSC.ZigString;
|
||||
const uv = bun.windows.libuv;
|
||||
|
||||
pub fn getBunServerAllClosedPromise(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(JSC.conv) JSC.JSValue {
|
||||
const arguments = callframe.arguments(1).slice();
|
||||
if (arguments.len < 1) {
|
||||
globalThis.throwNotEnoughArguments("getBunServerAllClosePromise", 1, arguments.len);
|
||||
return .zero;
|
||||
}
|
||||
|
||||
const value = arguments[0];
|
||||
|
||||
inline for ([_]type{
|
||||
JSC.API.HTTPServer,
|
||||
JSC.API.HTTPSServer,
|
||||
JSC.API.DebugHTTPServer,
|
||||
JSC.API.DebugHTTPSServer,
|
||||
}) |Server| {
|
||||
if (value.as(Server)) |server| {
|
||||
if (server.listener == null and server.pending_requests == 0) {
|
||||
return JSC.JSPromise.resolvedPromise(globalThis, .undefined).asValue(globalThis);
|
||||
}
|
||||
const prom = &server.all_closed_promise;
|
||||
if (prom.strong.has()) {
|
||||
return prom.value();
|
||||
}
|
||||
prom.* = JSC.JSPromise.Strong.init(globalThis);
|
||||
return prom.value();
|
||||
}
|
||||
}
|
||||
|
||||
return globalThis.throwInvalidArgumentTypeValue("server", "bun.Server", value);
|
||||
}
|
||||
Reference in New Issue
Block a user