Skip to content

Commit 08ba762

Browse files
committed
endpoint for getting file list done
1 parent c27ff4d commit 08ba762

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/client.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@ use req_packager::grpc::{dataset_service_client::DatasetServiceClient, BrowseDat
22

33
#[tokio::main]
44
async fn main() -> Result<(), Box<dyn std::error::Error>> {
5+
// TODO:
6+
// - client list all the files in a dataset
7+
// - client select some files and ask "what vre should I use"?
8+
// - with files and vre, create a ro-crate that contains all information inside (with
9+
// information of which file is in which vre input slots).
10+
// - client get the realtime status update from VRE and get a callback link send back when it
11+
// is ready.
512
let mut client = DatasetServiceClient::connect("http://[::1]:50051").await?;
613

714
// made up repo url and dataset id, should be mocked for test
8-
let url_datarepo = "http://onedata.com".to_string();
9-
let id_dataset = "xxx-pid".to_string();
15+
let url_datarepo = "https://example.com/datasets".to_string();
16+
let id_dataset = "1".to_string();
1017
let request = tonic::Request::new(BrowseDatasetRequest {
1118
url_datarepo,
1219
id_dataset,

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ struct Dataset {
5858
files: Vec<FileEntry>,
5959
}
6060

61+
// TODO: rename to DataRepositoryProxy??
62+
// This play the role to relay the API calls to source data repository through filemetrix service.
6163
pub struct DataRepoRelayer {
6264
// TODO: source of tool-registry, mocked by a JSON, in production can be just tool-registry
6365
// API call address.

src/server.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use url::Url;
2121

2222
use req_packager::VirtualResearchEnv;
2323

24-
#[derive(Clone)]
24+
#[derive(Clone, Debug)]
2525
struct Dataset {
2626
// XXX: I don't want to couple the grpc logic with business logic, so I need real type for both
2727
// datasetinfo and fileentry.
@@ -56,6 +56,7 @@ impl FilemetrixClient for MockFilemetrixClient {
5656
url_datarepo: &str,
5757
id: &str,
5858
) -> anyhow::Result<grpc::DatasetInfo> {
59+
// XXX: very fragile to use url+id, should be a PID or other primary key in DB.
5960
match self
6061
.datasets
6162
.get(&(url_datarepo.to_string(), id.to_string()))
@@ -169,7 +170,7 @@ impl DispatcherClient for MockDispatcherClient {
169170
}
170171
}
171172

172-
#[derive(Serialize, Deserialize, Clone)]
173+
#[derive(Serialize, Deserialize, Clone, Debug)]
173174
struct DatasetInfo {
174175
url: String,
175176
id: String,
@@ -204,7 +205,7 @@ impl From<DatasetInfo> for grpc::DatasetInfo {
204205
}
205206
}
206207

207-
#[derive(Serialize, Deserialize, Clone)]
208+
#[derive(Serialize, Deserialize, Clone, Debug)]
208209
struct FileEntry {
209210
path: String,
210211
is_dir: bool,
@@ -308,8 +309,8 @@ fn generate_datasets() -> Vec<Dataset> {
308309
}
309310

310311
let info = DatasetInfo {
311-
url: format!("https://example.com/datasets/{i}"),
312-
id: Uuid::new_v4().to_string(),
312+
url: "https://example.com/datasets".to_string(),
313+
id: format!("{i}"),
313314
description: format!("Mock dataset number {i}"),
314315
total_files: Some(total_files),
315316
total_size_bytes: Some(total_size_bytes),

0 commit comments

Comments
 (0)