Andrey Pechkurov
1 min readJan 1, 2019

--

Thanks for the feedback!

The overall approach should be applicable for IPC (as well as any other way of communication, e.g. plain TCP sockets, or WebSocket, or any message queue, etc.). The only change is how you store and obtain (i.e. serialize and deserialize) the correlation id (the request id, in case of HTTP) in each of your node processes.

If you’re using child_process module, you can send messages between parent and child processes (see the doc). In this scenario, you can add a general purpose metadata field for each of messages, then read the correlation id from CLS each time when a message is being send and add it into the metadata field. On receival of messages you should read from the metadata field and store the correlation id into CLS. And, of course, it’s better to encapsulate this logic in a separate module.

--

--

Andrey Pechkurov
Andrey Pechkurov

Written by Andrey Pechkurov

Core database engineer at QuestDB. Distributed systems gazer. Node.js contributor. Occasional tech blogger and speaker.

No responses yet