HomePhabricator
Diffusion Comm 51f80d6bdde0

[services] Tunnelbroker - Adding of gRPC `SessionSignature` implementation

Description

[services] Tunnelbroker - Adding of gRPC SessionSignature implementation

Summary:
This diff introduces the implementation of SessionSignature gRPC handler using the Rust Tonic gRPC server and by calling the sessionSignatureHandler C++ handler wrapper function. The new implementation is a wrapper of the current SessionSignature C++ handler.

The server/tools.rs file was created with the create_tonic_status function, which returns a Tonic status. The reason to create this function is that we can't cast the tonic::Code enum based on the number that received from the C++ sessionSignatureHandler function. Also, we can't use tonic::Code as a ffi/cxx return type, because the cxx build fails with an unsupported type error. I think that's because of the impl for the enum which C++/cxx doesn't support.

The grpcResult struct is created in the ffi section to pass gRPC errors from C++ handler to the Rust gRPC handler and return the error code and text by the gRPC server.

Linear task: ENG-2058

Test Plan:
1. Building:
The service was successfully built with the CI process or can be built manually using the cargo build command in services/tunnelbroker directory.

2. gRPC testings:
Run the service using the cargo run command. Open the gRPC client and call the SessionSignature request with the valid deviceID.
For example:

{
  "deviceID": "mobile:foS4IBADcn3uUNF8DEoH2jj6b8hujMsKUtNAKhJID4U50oalGWyg9rdLpgJwlmRy"
}

The expected result should be the toSign generated string from the server:

{
  "toSign": "7u1iiQNBlrsn0qy9BhlX8BJxttS6cBNnuCtJR1N9Mp8up56Qc4BEZWc9OvJYjlou"
}

Reviewers: jon, varun, marcin, tomek

Reviewed By: jon, tomek

Subscribers: ashoat, tomek, atul, abosh

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