Skip to content

Commit

Permalink
Merge branch 'main' of github.com:MarcusDunn/day-trader into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Wilson committed Apr 13, 2023
2 parents c8a6c86 + 74735ef commit a4e915b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
10 changes: 10 additions & 0 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::command::add::LoadTestAdd;
use crate::command::command_user_id_file_name::LoadTestDumpLogUserIdFileName;
use crate::command::dump_log::{DumpLog, LoadTestDumpLogFileName};
use crate::command::load_test_file::LoadTestFileCommand;
use crate::command::user_id::LoadTestUserIdCommand;
use crate::command::user_id_stock_symbol::LoadTestUserIdStockSymbolCommand;
use crate::command::user_id_stock_symbol_amount_created::LoadTestUserIdStockSymbolAmountCommand;
Expand All @@ -12,6 +13,7 @@ use tracing::debug;
pub mod add;
pub mod command_user_id_file_name;
pub mod dump_log;
pub mod load_test_file;
pub mod user_id;
pub mod user_id_stock_symbol;
pub mod user_id_stock_symbol_amount_created;
Expand Down Expand Up @@ -54,6 +56,8 @@ pub enum LoadTestCommand {
DumpLogUser(LoadTestDumpLogUserIdFileName),
/// Get the information about the user's current state
GetUserInfo(LoadTestUserIdCommand),
/// Get a log file from the server
File(LoadTestFileCommand),
}

impl LoadTestCommand {
Expand Down Expand Up @@ -113,6 +117,7 @@ impl LoadTestCommand {
LoadTestCommand::GetUserInfo(LoadTestUserIdCommand { user_id, .. }) => {
Some(user_id.clone())
}
LoadTestCommand::File(_) => None,
}
}

Expand Down Expand Up @@ -208,6 +213,11 @@ impl LoadTestCommand {
.get_user_info(get_user_info)
.await
.map(|resp| debug!("{resp:?}")),
LoadTestCommand::File(file) => client
.day_trader
.file(file)
.await
.map(|resp| debug!("{resp:?}")),
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions cli/src/command/load_test_file.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use crate::protos::FileRequest;
use proptest_derive::Arbitrary;
use tonic::{IntoRequest, Request};

#[derive(Debug, PartialEq, clap::Args, Clone, Arbitrary)]
pub struct LoadTestFileCommand {
/// the filename to fetch
file: String,
}

impl IntoRequest<FileRequest> for LoadTestFileCommand {
fn into_request(self) -> Request<FileRequest> {
Request::new(FileRequest {
filename: self.file,
})
}
}
4 changes: 2 additions & 2 deletions protos/day-trader.proto
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ service DayTrader {
}

message FileRequest {
string filename = 2;
string filename = 1;
}

message FileResponse {
bytes contents = 2;
bytes contents = 1;
}

message QuoteRequestSimple {
Expand Down

0 comments on commit a4e915b

Please sign in to comment.