From 2e3fb272205c571492f43e71cfa7747bf6149e17 Mon Sep 17 00:00:00 2001 From: Igor Lins e Silva <4753812+igorls@users.noreply.github.com> Date: Sat, 2 Nov 2024 04:09:53 -0300 Subject: [PATCH] types: add AppDescriptor type and methods for worker threads Added: - AppDescriptor interface as a native type (similar to us_listen_socket) - Methods on TemplatedApp: - getDescriptor() - addChildAppDescriptor() - removeChildAppDescriptor() --- docs/index.d.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/index.d.ts b/docs/index.d.ts index 5199f608..564ec09e 100644 --- a/docs/index.d.ts +++ b/docs/index.d.ts @@ -32,6 +32,14 @@ export interface us_socket_context_t { } +/** Native type representing a raw uWebSockets struct AppDescriptor. + * Used internally for worker thread distribution. + * Careful with this one, it is entirely unchecked and native so invalid usage will blow up. + */ +export interface AppDescriptor { + +} + /** Recognized string types, things C++ can read and understand as strings. * "String" does not have to mean "text", it can also be "binary". * @@ -331,6 +339,12 @@ export interface TemplatedApp { filter(cb: (res: HttpResponse, count: Number) => void | Promise) : TemplatedApp; /** Closes all sockets including listen sockets. This will forcefully terminate all connections. */ close() : TemplatedApp; + /** Returns the app descriptor for worker thread distribution. */ + getDescriptor(): AppDescriptor; + /** Add a child app descriptor for worker thread distribution. */ + addChildAppDescriptor(descriptor: AppDescriptor): void; + /** Remove a child app descriptor. */ + removeChildAppDescriptor(descriptor: AppDescriptor): void; } /** Constructs a non-SSL app. An app is your starting point where you attach behavior to URL routes.