[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:
- Restart RabbitMQ
- Restart localstack
- 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(); }
- Open RabbitMQ management console, there should be one dropped message (there is no device with test_persist ID)
- Open DynamoDB console, message should be persisted:
- 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