Skip to content

Commit 74735ef

Browse files
authored
Merge pull request #114 from MarcusDunn/cli-file-support
added file support
2 parents abc9ddc + 2e11c4c commit 74735ef

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

cli/src/command.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::command::add::LoadTestAdd;
22
use crate::command::command_user_id_file_name::LoadTestDumpLogUserIdFileName;
33
use crate::command::dump_log::{DumpLog, LoadTestDumpLogFileName};
4+
use crate::command::load_test_file::LoadTestFileCommand;
45
use crate::command::user_id::LoadTestUserIdCommand;
56
use crate::command::user_id_stock_symbol::LoadTestUserIdStockSymbolCommand;
67
use crate::command::user_id_stock_symbol_amount_created::LoadTestUserIdStockSymbolAmountCommand;
@@ -12,6 +13,7 @@ use tracing::debug;
1213
pub mod add;
1314
pub mod command_user_id_file_name;
1415
pub mod dump_log;
16+
pub mod load_test_file;
1517
pub mod user_id;
1618
pub mod user_id_stock_symbol;
1719
pub mod user_id_stock_symbol_amount_created;
@@ -54,6 +56,8 @@ pub enum LoadTestCommand {
5456
DumpLogUser(LoadTestDumpLogUserIdFileName),
5557
/// Get the information about the user's current state
5658
GetUserInfo(LoadTestUserIdCommand),
59+
/// Get a log file from the server
60+
File(LoadTestFileCommand),
5761
}
5862

5963
impl LoadTestCommand {
@@ -113,6 +117,7 @@ impl LoadTestCommand {
113117
LoadTestCommand::GetUserInfo(LoadTestUserIdCommand { user_id, .. }) => {
114118
Some(user_id.clone())
115119
}
120+
LoadTestCommand::File(_) => None,
116121
}
117122
}
118123

@@ -208,6 +213,11 @@ impl LoadTestCommand {
208213
.get_user_info(get_user_info)
209214
.await
210215
.map(|resp| debug!("{resp:?}")),
216+
LoadTestCommand::File(file) => client
217+
.day_trader
218+
.file(file)
219+
.await
220+
.map(|resp| debug!("{resp:?}")),
211221
}
212222
}
213223
}

cli/src/command/load_test_file.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::protos::FileRequest;
2+
use proptest_derive::Arbitrary;
3+
use tonic::{IntoRequest, Request};
4+
5+
#[derive(Debug, PartialEq, clap::Args, Clone, Arbitrary)]
6+
pub struct LoadTestFileCommand {
7+
/// the filename to fetch
8+
file: String,
9+
}
10+
11+
impl IntoRequest<FileRequest> for LoadTestFileCommand {
12+
fn into_request(self) -> Request<FileRequest> {
13+
Request::new(FileRequest {
14+
filename: self.file,
15+
})
16+
}
17+
}

protos/day-trader.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ service DayTrader {
4747
}
4848

4949
message FileRequest {
50-
string filename = 2;
50+
string filename = 1;
5151
}
5252

5353
message FileResponse {
54-
bytes contents = 2;
54+
bytes contents = 1;
5555
}
5656

5757
message QuoteRequestSimple {

0 commit comments

Comments
 (0)