totaljs / framework4

Total.js framework v4
https://www.totaljs.com
Other
97 stars 36 forks source link

Alternative to Unix socket via Worker_threads module #6

Closed dispbd closed 1 year ago

dispbd commented 3 years ago

V4 has the ability to run the framework through threads. Their implementation is built by the Unix socket. More details: https://docs.totaljs.com/total4/40840001xi51c/

However, unix sockets are not supported everywhere, which partially limits this functionality on some systems. My idea is to start threads not through sockets (that is, in fact, separate processes), but through the built-in node.js module - worker_threads.

The bottom line is that threads in node.js are not separate processes, but just separate chunks of memory. And that's why their control and interaction is so much easier. It is easy for streams to transfer any data, as well as it is easy to receive it back. I believe the ip and port can just be streamed as data. Next, you can write a function to check whether the port and ip address match. Since a thread can return any data, validation shouldn't be difficult either. Read the second point in this discussion for more details https://github.com/totaljs/framework4/issues/4

In the coming weeks (as time permits), I'll share my ideas in code. Any help, questions or criticism is appreciated!

petersirka commented 1 year ago

I have implemented it partially on the Windows via Windows pipe.