HomePhabricator
Diffusion Comm 7f909f15c049

[Tunnelbroker] always persist gRPC messages in database

Description

[Tunnelbroker] always persist gRPC messages in database

Summary:

  • We need to make sure that each message is delivered to client.
  • We need to persist it immediately after receiving
  • Message will be removed after confirmation from client

Depends on D9312

Test Plan:

  1. Restart RabbitMQ
  2. Restart localstack
  3. Run this code:
#[tokio::test]
async fn send_grpc() {
  let refresh_request = RefreshKeyRequest {
    device_id: "test_persist".to_string(),
    number_of_keys: 5,
  };

  let request = MessageToDevice {
    device_id: "test_persist".to_string(),
    payload: serde_json::to_string(&refresh_request).unwrap(),
  };
  let grpc_message = tonic::Request::new(request);

  TunnelbrokerServiceClient::connect("http://localhost:50051")
    .await
    .unwrap()
    .send_message_to_device(grpc_message)
    .await
    .unwrap();
}
  1. Open RabbitMQ management console, there should be one dropped message (there is no device with test_persist ID)

Screenshot 2023-09-27 at 15.48.09.png (224×641 px, 28 KB)

  1. Open DynamoDB console, message should be persisted:

Screenshot 2023-09-27 at 15.48.25.png (513×1 px, 64 KB)

  1. Additionally, check TB logs for:
2023-09-27T13:47:23.107877Z DEBUG tunnelbroker::grpc: Received message for test_persist
2023-09-27T13:47:23.107920Z DEBUG tunnelbroker::database: Persisting message to device: test_persist

Reviewers: michal, bartek, varun, jon

Reviewed By: bartek

Subscribers: ashoat, tomek

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

Details

Provenance
kamilAuthored on Sep 27 2023, 6:54 AM
Reviewer
bartek
Differential Revision
D9313: [Tunnelbroker] always persist gRPC messages in database
Parents
rCOMM2a40ae7bdba7: [lib] Disable chat mentioning
Branches
Unknown
Tags
Unknown