Created
September 13, 2020 16:12
-
-
Save jayhuang75/ebadf5a4cdd04ab5a972f383d773e276 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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