Skip to content

Commit

Permalink
Merge pull request #141 from BobAnkh/dev
Browse files Browse the repository at this point in the history
refactor(backend): reorganize codes to workspace style
  • Loading branch information
BobAnkh committed Dec 29, 2021
2 parents d2f6863 + 4ab6d8a commit 19cc695
Show file tree
Hide file tree
Showing 76 changed files with 8,113 additions and 5,221 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/backend-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
working-directory: backend

- name: cargo check
run: cargo check --all-targets
run: cargo check --all-targets --workspace

cargo-build:
runs-on: ubuntu-latest
Expand All @@ -65,7 +65,7 @@ jobs:
working-directory: backend

- name: cargo build
run: cargo build
run: cargo build --workspace

cargo-clippy:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
uses: BobAnkh/clippy-check@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
args: --all-features --workspace
working-directory: backend


Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:
working-directory: backend

- name: cargo fmt
run: cargo fmt -- --check
run: cargo fmt --all -- --check

# cargo-udeps:
# runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/frontend-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
- frontend
pull_request:
types: [ready_for_review, opened, synchronize, reopened]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# THUBurrow

![language-python](https://img.shields.io/github/languages/top/BobAnkh/THUBurrow?logo=rust&logoColor=orange)
![language](https://img.shields.io/github/languages/top/BobAnkh/THUBurrow?logo=rust&logoColor=orange)
[![codecov](https://codecov.io/gh/BobAnkh/THUBurrow/branch/main/graph/badge.svg?token=7QP055B1UK)](https://codecov.io/gh/BobAnkh/THUBurrow)
[![Rust Report Card](https://rust-reportcard.xuri.me/badge/github.com/BobAnkh/THUBurrow)](https://rust-reportcard.xuri.me/report/github.com/BobAnkh/THUBurrow)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/862ff67005124246a0811c1f8e47ea6d)](https://www.codacy.com/gh/BobAnkh/THUBurrow/dashboard?utm_source=github.com&utm_medium=referral&utm_content=BobAnkh/THUBurrow&utm_campaign=Badge_Grade)

![GitHub release (latest by date)](https://img.shields.io/github/v/release/BobAnkh/THUBurrow?color=orange&logo=github-actions)
![LICENSE GPL-3.0](https://img.shields.io/github/license/BobAnkh/THUBurrow?logo=gpl)

Expand Down
54 changes: 43 additions & 11 deletions backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 9 additions & 60 deletions backend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,60 +1,9 @@
[package]
name = "backend"
version = "1.0.0"
edition = "2018"
authors = ["BobAnkh <bobankhshen@gmail.com>"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dev-dependencies]
once_cell = "1.8.0"
parking_lot = "0.11.2"
criterion = "0.3"

[[test]]
name = "integration"
path = "tests/lib.rs"

[[bench]]
name = "backend_bench"
harness = false

[dependencies]
chrono = { version = "0.4", features = ["serde"] }
log = "0.4"
rocket = { git = "https://github.com/SergioBenitez/Rocket", branch = "master", features = [
"json",
"uuid",
"secrets",
] }
rocket_db_pools = { git = "https://github.com/SergioBenitez/Rocket", branch = "master", features = [
"sqlx_postgres",
] }
sea-orm = { version = "0.4.0", features = [
"sqlx-postgres",
"runtime-tokio-rustls",
"macros",
], default-features = false }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
uuid = { version = "0.8.2", features = ["v4", "v5", "serde"] }
rust-crypto = "0.2.36"
deadpool = { version = "0.9.0", features = ["managed", "rt_tokio_1"]}
deadpool-redis = { version = "0.10.0", features = ["rt_tokio_1", "serde"] }
redis = { version = "0.21"}
idgenerator = "1.2.0"
rocket_cors = { git = "https://github.com/BobAnkh/rocket_cors.git", branch = "master"}
pulsar = "4.1.1"
futures = "0.3"
tokio = { version = "1.13.0", features = ["macros", "rt-multi-thread", "parking_lot", "signal"] }
reqwest = { version = "0.11", features = ["json", "blocking", "cookies"] }
rust-s3 = "0.27.0"
log4rs = "1.0.0"
rand = "0.8.4"
time = "0.3.4"
regex = "1.5.4"
lazy_static = "1.4.0"
check-if-email-exists = "0.8"
async-smtp = "0.4.0"
toml = "0.5.8"
hex = "0.4.3"
[workspace]
members = [
"core",
"task-executor",

# Internal
"tests-integration",
"benches",
]
4 changes: 2 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN cargo build --release
RUN cargo build --release -p backend -p task-executor

# FINAL
FROM debian:buster-slim
Expand All @@ -25,7 +25,7 @@ RUN apt update -qq && \
apt install --no-install-recommends libssl-dev curl procps -y && \
rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/backend /usr/local/bin/backend
COPY --from=builder /app/target/release/task_executor /usr/local/bin/task_executor
COPY --from=builder /app/target/release/task-executor /usr/local/bin/task-executor
COPY --from=builder /app/Rocket.toml /etc/backend/Rocket.toml
COPY --from=builder /app/conf/log4rs.yml /etc/backend/conf/log4rs-default.yml
COPY --from=builder /app/docker-entrypoint.sh /
Expand Down
16 changes: 16 additions & 0 deletions backend/benches/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "benches"
version = "0.0.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
backend = { path = "../core" }
criterion = "0.3"
idgenerator = "1.2.0"

[[bench]]
name = "core_bench"
path = "core_bench.rs"
harness = false
File renamed without changes.
65 changes: 65 additions & 0 deletions backend/core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[package]
name = "backend"
version = "1.0.0"
edition = "2018"
authors = ["BobAnkh <bobankhshen@gmail.com>"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dev-dependencies]
once_cell = "1.8.0"
parking_lot = "0.11.2"
criterion = "0.3"

# [[test]]
# name = "integration"
# path = "tests/lib.rs"

# [[bench]]
# name = "backend_bench"
# harness = false

[dependencies]
chrono = { version = "0.4", features = ["serde"] }
log = "0.4"
rocket = { git = "https://github.com/SergioBenitez/Rocket", branch = "master", features = [
"json",
"uuid",
"secrets",
] }
rocket_db_pools = { git = "https://github.com/SergioBenitez/Rocket", branch = "master", features = [
"sqlx_postgres",
] }
sea-orm = { version = "0.4.0", features = [
"sqlx-postgres",
"runtime-tokio-rustls",
"macros",
], default-features = false }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
uuid = { version = "0.8.2", features = ["v4", "v5", "serde"] }
rust-crypto = "0.2.36"
deadpool = { version = "0.9.0", features = ["managed", "rt_tokio_1"] }
deadpool-redis = { version = "0.10.0", features = ["rt_tokio_1", "serde"] }
redis = { version = "0.21" }
idgenerator = "1.2.0"
rocket_cors = { git = "https://github.com/BobAnkh/rocket_cors.git", branch = "master" }
pulsar = "4.1.1"
futures = "0.3"
tokio = { version = "1.13.0", features = [
"macros",
"rt-multi-thread",
"parking_lot",
"signal",
] }
reqwest = { version = "0.11", features = ["json", "blocking", "cookies"] }
rust-s3 = "0.28.0"
log4rs = "1.0.0"
rand = "0.8.4"
time = "0.3.4"
regex = "1.5.4"
lazy_static = "1.4.0"
check-if-email-exists = "0.8"
async-smtp = "0.4.0"
toml = "0.5.8"
hex = "0.4.3"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use rocket::{Build, Rocket};
use rocket_db_pools::Connection;
use sea_orm::{entity::*, ConnectionTrait, DbErr};

#[cfg(debug_assertions)]
use crate::config::BACKEND_TEST_MODE;
use crate::db::{self, prelude::*};
use crate::models::pulsar::{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion backend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
ROCKET_DATABASES: '{pgdb={url="postgres://postgres:${PG_PASSWORD:-postgres}@pgdb:5432/${PG_DB:-pgdb}"},redis={url="redis://:${KEYDB_PASSWORD:-keypassword}@keydb:6379"},minio={url="minio://${MINIO_USER:-minio}:${MINIO_PASSWORD:-miniopassword}@minio:9000"},pulsar-mq={url="pulsar://pulsar:6650"},search={url="http://typesense:8108@${TYPESENSE_API_KEY:-8Dz4jRrsBjYgdCD/VGP1bleph7oBThJr5IcF43l0U24=}"}}'
ROCKET_SECRET_KEY: ${ROCKET_SECRET_KEY}
ROCKET_ADDRESS: "0.0.0.0"
VIRTUAL_HOST: ${BACKEND_HOST}
# VIRTUAL_HOST: ${BACKEND_HOST}
SECRET_ID: ${SECRET_ID}
SECRET_KEY: ${SECRET_KEY}
networks:
Expand Down
10 changes: 5 additions & 5 deletions backend/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
# @Author : BobAnkh
# @Github : https://github.com/BobAnkh
# @Date : 2021-12-02 16:51:50
# @LastEditors : BobAnkh
# @LastEditTime : 2021-12-19 11:19:44
# @LastEditors : BobAnkh
# @LastEditTime : 2021-12-29 13:50:40
# @Description :
# Copyright 2021 BobAnkh
###

kill_backend() {
echo "$(date -u "+%Y-%m-%d %H:%M:%S UTC") Received TERM, gracefully exiting..."
kill "$(pgrep backend)"
kill "$(pgrep task_executor)"
wait $!
kill "$(pgrep task-executor)"
wait "$(pgrep task-executor)"
echo "$(date -u "+%Y-%m-%d %H:%M:%S UTC") Process finished"
}

trap 'kill_backend' TERM INT
echo "$(date -u "+%Y-%m-%d %H:%M:%S UTC") [ENTRYPOINT] Running Background Task Executor"
task_executor &
task-executor &
echo "$(date -u "+%Y-%m-%d %H:%M:%S UTC") [ENTRYPOINT] Running Backend"
backend &
wait $!
Loading

0 comments on commit 19cc695

Please sign in to comment.