totaljs/framework4

Alternative to Unix socket via Worker_threads module

Closed this issue · 1 comments

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 #4

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

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