HomePhabricator
Diffusion Comm a1400b0cb428

[keyserver] Adding Tunnelbroker-client napi-rs class constructor

Description

[keyserver] Adding Tunnelbroker-client napi-rs class constructor

Summary:
This diff introduces a napi-rs JS class constructor for using the shared Tunnelbroker-client library in the keyserver's node codebase.
Using the napi-rs class constructor we can use the client as a standard class inside the keyserver's JS codebase.

The class constructor has two arguments:

  • Address where to connect to the Tunnelbroker;
  • JS Callback function which is called when the message in the input stream is received. The message payload is used as an argument to the callback function;

The constructor connects to the Tunnelbroker server, spawning a tokio task to listen for new messages from the stream and call the callback function on it.

Linear task: ENG-2729

Test Plan:

  1. Keyserver service is successfully built.
  2. Manually testing:
    • Start the Tunnelbroker server;
    • Create a TunnelbrokerClient in a node js codebase by passing the address and a callback function.

The concept was tested using the echo bidi stream and simple client in the testing repo.

Reviewers: varun, jon, bartek

Reviewed By: varun

Subscribers: ashoat, tomek, atul

Differential Revision: https://phab.comm.dev/D6459