Skip to content

Instantly share code, notes, and snippets.

@jayhuang75
Created September 13, 2020 16:12
Show Gist options
  • Save jayhuang75/ebadf5a4cdd04ab5a972f383d773e276 to your computer and use it in GitHub Desktop.
Save jayhuang75/ebadf5a4cdd04ab5a972f383d773e276 to your computer and use it in GitHub Desktop.
// Init logging
env_logger::init();
let channel = tonic::transport::Channel::from_static("http://[::0]:50051")
.connect()
.await?;
let mut client = PlayerServiceClient::new(channel);
let mut sent_data = Vec::new();
let mut rng = rand::thread_rng();
for _x in 0..100 {
sent_data.push(PlayerData {
device_id: "demo-device-001".to_string(),
player_id: "1234567".to_string(),
performances: Some(Performances {
hr: rng.gen::<f32>(),
temperature: rng.gen::<f32>(),
acceleration: Some(Acceleration {
x: rng.gen::<f32>(),
y: rng.gen::<f32>(),
z: rng.gen::<f32>(),
}),
gyro: Some(Gyro {
x: rng.gen::<f32>(),
y: rng.gen::<f32>(),
z: rng.gen::<f32>(),
}),
magnetic: Some(Magnetic {
x: rng.gen::<f32>(),
y: rng.gen::<f32>(),
z: rng.gen::<f32>(),
}),
location: Some(Location {
x: rng.gen::<f32>(),
y: rng.gen::<f32>(),
z: rng.gen::<f32>(),
}),
}),
});
}
info!("sent_data lenght: {:?}", sent_data.len());
let request = tonic::Request::new(stream::iter(sent_data));
client.player_rpc(request).await?;
Ok(())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment