-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from umccr/filemanager
FileManager microservice
- Loading branch information
Showing
22 changed files
with
2,617 additions
and
26 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,7 @@ cdk.context.json | |
!.yarn/versions | ||
|
||
*.sqlite3 | ||
|
||
# SQL dumps, data, etc... | ||
|
||
data/ |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Rust API Profile | ||
|
||
- Use this profile if your microservice needs: ORM, API, LAMBDA, SQS | ||
|
||
## App | ||
|
||
- Consider building a microservice: `rust-api` | ||
|
||
## Quickstart | ||
|
||
Assuming you already have the Rust toolchain installed on your system, otherwise install it via: | ||
|
||
```bash | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh | ||
``` | ||
|
||
For development edit and compile loop, use the [`cargo-watch`](https://crates.io/crates/cargo-watch) crate: | ||
|
||
``` | ||
$ cargo install cargo-watch # if not installed previously | ||
$ cargo watch -c -w src -x run # Watches "src" dir, eXecutes "cargo run" | ||
Compiling rust-api v0.1.0 (/Users/rvalls/dev/umccr/orcabus/skel/rust-api) | ||
Finished dev [unoptimized + debuginfo] target(s) in 1.74s | ||
Running `target/debug/rust-api` | ||
2023-06-13T00:56:41.621002Z INFO rust_api: listening on 0.0.0.0:8080 | ||
``` | ||
|
||
Then: | ||
|
||
``` | ||
$ curl localhost:8080/file/moo.bam | ||
``` | ||
|
||
And to access the builtin Swagger playground, visit http://localhost:8080/swagger-ui/ on your browser. | ||
|
||
# Database | ||
|
||
Since this microservice is reliant on (meta)data present on the former "Data Portal" database, we'll have to load those tables in on the `orcabus_db` container and inner MySQL DB like so: | ||
|
||
```bash | ||
aws s3 cp s3://<data-portal-dev-bucket>/data_portal.sql.gz data/ | ||
docker cp data/data_portal.sql.gz orcabus_db:/ | ||
docker exec -i -e MYSQL_PWD=orcabus orcabus_db mysql -u orcabus -e "DROP DATABASE IF EXISTS orcabus; CREATE DATABASE IF NOT EXISTS orcabus;" | ||
docker exec -i -e MYSQL_PWD=orcabus orcabus_db /bin/bash -c 'zcat data_portal.sql.gz | mysql -uorcabus orcabus' | ||
``` | ||
|
||
# Rust learning | ||
|
||
While at first Rust can seem intimidating (as a language), there's plenty of materials online that can help you get up to speed with this microservice codebase, check this out: | ||
|
||
- [Google 3-day Rust course](https://github.com/google/comprehensive-rust) | ||
- [SQLx quickstart](https://www.youtube.com/watch?v=TCERYbgvbq0) | ||
- [Rust Axum full course](https://www.youtube.com/watch?v=XZtlD_m59sM) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,6 @@ | ||
# OpenAPI | ||
# Orcabus microservices OpenAPI client definitions | ||
|
||
This directory contains OpenAPI/Swagger JSON files. They are generated/obtained as follows. | ||
Each language implementation should make sure to expose an `api-docs` and `swagger-ui` url routes that expose the APIs for a given microservice, i.e: | ||
|
||
## ICA | ||
|
||
Sync of https://github.com/umccr-illumina/libica/tree/dev/swagger | ||
|
||
``` | ||
wget https://raw.githubusercontent.com/umccr-illumina/libica/dev/swagger/console.json -O console.json | ||
wget https://raw.githubusercontent.com/umccr-illumina/libica/dev/swagger/ens.json -O ens.json | ||
wget https://raw.githubusercontent.com/umccr-illumina/libica/dev/swagger/gds.json -O gds.json | ||
wget https://raw.githubusercontent.com/umccr-illumina/libica/dev/swagger/tes.json -O tes.json | ||
wget https://raw.githubusercontent.com/umccr-illumina/libica/dev/swagger/wes.json -O wes.json | ||
wget https://raw.githubusercontent.com/umccr-illumina/libica/main/swagger/openapi_public.yaml -O openapi_public.yaml | ||
``` | ||
http://localhost:8080/swagger-ui/ | ||
http://localhost:8080/api-docs/filemanager.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# OpenAPI | ||
|
||
This directory contains OpenAPI/Swagger JSON files. They are generated/obtained as follows. | ||
|
||
## ICA | ||
|
||
Sync of https://github.com/umccr-illumina/libica/tree/dev/swagger | ||
|
||
``` | ||
wget https://raw.githubusercontent.com/umccr-illumina/libica/dev/swagger/console.json -O console.json | ||
wget https://raw.githubusercontent.com/umccr-illumina/libica/dev/swagger/ens.json -O ens.json | ||
wget https://raw.githubusercontent.com/umccr-illumina/libica/dev/swagger/gds.json -O gds.json | ||
wget https://raw.githubusercontent.com/umccr-illumina/libica/dev/swagger/tes.json -O tes.json | ||
wget https://raw.githubusercontent.com/umccr-illumina/libica/dev/swagger/wes.json -O wes.json | ||
``` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This is the OpenAPI ICA v2 definition, obtained from upstream: | ||
|
||
wget https://raw.githubusercontent.com/umccr-illumina/libica/main/swagger/openapi_public.yaml -O openapi_public.yaml |
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"openapi":"3.0.3","info":{"title":"rust-api","description":"","license":{"name":""},"version":"0.1.0"},"paths":{"/file/":{"get":{"tags":["file"],"summary":"Search query","description":"Search query\nSearch files","operationId":"search","parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"integer","format":"int32"}},{"name":"name","in":"query","required":true,"schema":{"type":"string"}},{"name":"size","in":"query","required":true,"schema":{"type":"integer","format":"int64","minimum":0.0}},{"name":"hash","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"List matching objects","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/File"}}}}}}}}},"components":{"schemas":{"File":{"type":"object","description":"Item to do.","required":["id","name","size","hash"],"properties":{"hash":{"type":"string"},"id":{"type":"integer","format":"int32"},"name":{"type":"string","example":"foo.bam"},"size":{"type":"integer","format":"int64","minimum":0.0}}},"FileError":{"oneOf":[{"type":"object","required":["NotFound"],"properties":{"NotFound":{"type":"string","description":"File not found by id."}},"example":"id = 1"},{"type":"object","required":["Unauthorized"],"properties":{"Unauthorized":{"type":"string","description":"File operation unauthorized"}},"example":"missing api key"}],"description":"File operation errors"}},"securitySchemes":{"api_key":{"type":"apiKey","in":"header","name":"File_apikey"}}},"tags":[{"name":"File","description":"File manager API"}]} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
target/ | ||
*.swp |
Oops, something went wrong.