Skip to content

Commit

Permalink
Hide common three-party dependencies. close #11
Browse files Browse the repository at this point in the history
  • Loading branch information
gudaoxuri committed Jul 29, 2022
1 parent 201859f commit 7fd82fd
Show file tree
Hide file tree
Showing 33 changed files with 87 additions and 79 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,18 @@ Dependency Configuration
```toml
[dependencies]
tardis = { version = "^0", features = ["web-server"] }
poem-openapi = { version = "^2"}
```

Processor Configuration
```ignore
use tardis::basic::error::TardisError;
use tardis::web::poem_openapi;
use tardis::web::poem_openapi::param::Query;
use tardis::web::web_resp::{TardisApiResult, TardisResp};
pub struct Api;
#[OpenApi]
#[poem_openapi::OpenApi]
impl Api {
#[oai(path = "/hello", method = "get")]
async fn index(&self, name: Query<Option<String>>) -> TardisResult<String> {
Expand All @@ -85,6 +89,12 @@ impl Api {

Startup class configuration
```ignore
use tardis::basic::result::TardisResult;
use tardis::tokio;
use tardis::TardisFuns;
use crate::processor::Api;
mod processor;
#[tokio::main]
async fn main() -> TardisResult<()> {
// Initial configuration
Expand Down
13 changes: 0 additions & 13 deletions examples/Cargo.toml

This file was deleted.

1 change: 1 addition & 0 deletions examples/cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "tardis-example-cache"
version = "0.1.0"
authors = ["gudaoxuri"]
edition = "2021"
publish = false

[dependencies]
tardis = { path = "../..", features = ["cache", "test"] }
Expand Down
1 change: 0 additions & 1 deletion examples/cache/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::env;
use std::time::Duration;

use tardis::basic::result::TardisResult;
use tardis::test::test_container::TardisTestContainer;
use tardis::testcontainers::clients;
Expand Down
1 change: 1 addition & 0 deletions examples/mq/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "tardis-example-mq"
version = "0.1.0"
authors = ["gudaoxuri"]
edition = "2021"
publish = false

[dependencies]
tardis = { path = "../..", features = ["mq", "test"] }
Expand Down
1 change: 1 addition & 0 deletions examples/multi-apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "tardis-example-multi-apps"
version = "0.1.0"
authors = ["gudaoxuri"]
edition = "2021"
publish = false

[dependencies]
tardis-example-multi-apps-doc = { path = "doc"}
Expand Down
4 changes: 1 addition & 3 deletions examples/multi-apps/doc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ name = "tardis-example-multi-apps-doc"
version = "0.1.0"
authors = ["gudaoxuri"]
edition = "2021"
publish = false

[dependencies]
serde = { version = "1", features = ["derive"] }

tardis = { path = "../../..", features = ["reldb", "web-server"] }
sea-orm = { version = "0.9", features = ["macros"] }
poem-openapi = { version = "2" }
5 changes: 3 additions & 2 deletions examples/multi-apps/doc/src/api/doc_api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use tardis::web::context_extractor::TardisContextExtractor;
use tardis::web::poem_openapi::{payload::Json, OpenApi};
use tardis::web::poem_openapi;
use tardis::web::poem_openapi::payload::Json;
use tardis::web::web_resp::{TardisApiResult, TardisResp};
use tardis::TardisFuns;

Expand All @@ -8,7 +9,7 @@ use crate::serv::doc_serv::DocServ;

pub struct DocApi;

#[OpenApi(prefix_path = "/doc")]
#[poem_openapi::OpenApi(prefix_path = "/doc")]
impl DocApi {
/// Add
#[oai(path = "/", method = "post")]
Expand Down
1 change: 1 addition & 0 deletions examples/multi-apps/doc/src/domain/doc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use tardis::basic::dto::TardisContext;
use tardis::db::reldb_client::TardisActiveModel;
use tardis::db::sea_orm;
use tardis::db::sea_orm::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
Expand Down
4 changes: 2 additions & 2 deletions examples/multi-apps/doc/src/dto/doc_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::fmt::Debug;
use serde::{Deserialize, Serialize};

use tardis::basic::field::TrimString;
use tardis::web::poem_openapi::Object;
use tardis::web::poem_openapi;

#[derive(Object, Serialize, Deserialize, Debug)]
#[derive(poem_openapi::Object, Serialize, Deserialize, Debug)]
pub struct DocAddReq {
#[oai(validator(min_length = "2", max_length = "255"))]
pub name: TrimString,
Expand Down
4 changes: 1 addition & 3 deletions examples/multi-apps/tag/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ name = "tardis-example-multi-apps-tag"
version = "0.1.0"
authors = ["gudaoxuri"]
edition = "2021"
publish = false

[dependencies]
serde = { version = "1", features = ["derive"] }

tardis = { path = "../../..", features = ["reldb", "web-server"] }
sea-orm = { version = "0.9", features = ["macros"] }
poem-openapi = { version = "2" }
10 changes: 5 additions & 5 deletions examples/multi-apps/tag/src/api/tag_api.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use crate::dto::tag_dto::{TagAddReq, TagResp};
use crate::serv::tag_serv::TagServ;
use tardis::web::context_extractor::TardisContextExtractor;
use tardis::web::poem_openapi::{payload::Json, OpenApi};
use tardis::web::poem_openapi;
use tardis::web::poem_openapi::payload::Json;
use tardis::web::web_resp::{TardisApiResult, TardisResp};
use tardis::TardisFuns;

use crate::dto::tag_dto::{TagAddReq, TagResp};
use crate::serv::tag_serv::TagServ;

pub struct TagApi;

#[OpenApi(prefix_path = "/tag")]
#[poem_openapi::OpenApi(prefix_path = "/tag")]
impl TagApi {
/// Add
#[oai(path = "/", method = "post")]
Expand Down
1 change: 1 addition & 0 deletions examples/multi-apps/tag/src/domain/tag.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use tardis::basic::dto::TardisContext;
use tardis::db::reldb_client::TardisActiveModel;
use tardis::db::sea_orm;
use tardis::db::sea_orm::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
Expand Down
8 changes: 4 additions & 4 deletions examples/multi-apps/tag/src/dto/tag_dto.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
use std::fmt::Debug;

use sea_orm::FromQueryResult;
use serde::{Deserialize, Serialize};

use tardis::web::poem_openapi::Object;
use tardis::db::sea_orm;
use tardis::web::poem_openapi;

#[derive(Object, Serialize, Deserialize, Debug)]
#[derive(poem_openapi::Object, Serialize, Deserialize, Debug)]
#[oai(rename_all = "camelCase")]
pub struct TagAddReq {
pub name: String,
pub create_id: String,
}

#[derive(Object, Serialize, Deserialize, Debug, FromQueryResult)]
#[derive(poem_openapi::Object, Serialize, Deserialize, Debug, sea_orm::FromQueryResult)]
#[oai(rename_all = "camelCase")]
pub struct TagResp {
pub id: i32,
Expand Down
7 changes: 2 additions & 5 deletions examples/perf-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ name = "tardis-example-perf-test"
version = "0.1.0"
authors = ["gudaoxuri"]
edition = "2021"
publish = false

[dependencies]
# Tardis Functions
tardis = { path = "../..", features = ["web-server", "reldb"] }
# Web server dependencies
poem-openapi = { version = "2" }
# Reldb dependencies
sea-orm = { version = "0.9", features = ["macros"] }
tardis = { path = "../..", features = ["web-server", "reldb"] }
1 change: 1 addition & 0 deletions examples/perf-test/src/domain/todos.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use tardis::basic::dto::TardisContext;
use tardis::db::reldb_client::TardisActiveModel;
use tardis::db::sea_orm;
use tardis::db::sea_orm::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
Expand Down
12 changes: 7 additions & 5 deletions examples/perf-test/src/processor.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
use tardis::basic::dto::TardisContext;
use tardis::db::sea_orm;
use tardis::db::sea_orm::sea_query::Query as DbQuery;
use tardis::db::sea_orm::*;
use tardis::serde::{self, Deserialize, Serialize};
use tardis::web::poem_openapi;
use tardis::web::poem_openapi::param::Query;
use tardis::web::poem_openapi::{param::Path, payload::Json, Object, OpenApi};
use tardis::web::poem_openapi::{param::Path, payload::Json};
use tardis::web::web_resp::{TardisApiResult, TardisPage, TardisResp};
use tardis::TardisFuns;

use crate::domain::todos;

#[derive(Object, FromQueryResult, Serialize, Deserialize, Debug)]
#[derive(poem_openapi::Object, sea_orm::FromQueryResult, Serialize, Deserialize, Debug)]
#[serde(crate = "self::serde")]
struct TodoDetailResp {
id: i32,
description: String,
done: bool,
}

#[derive(Object, Serialize, Deserialize, Debug)]
#[derive(poem_openapi::Object, Serialize, Deserialize, Debug)]
#[serde(crate = "self::serde")]
struct TodoAddReq {
#[oai(validator(min_length = "2", max_length = "255"))]
description: String,
done: bool,
}

#[derive(Object, Serialize, Deserialize, Debug)]
#[derive(poem_openapi::Object, Serialize, Deserialize, Debug)]
#[serde(crate = "self::serde")]
struct TodoModifyReq {
#[oai(validator(min_length = "2", max_length = "255"))]
Expand All @@ -35,7 +37,7 @@ struct TodoModifyReq {

pub struct TodoApi;

#[OpenApi]
#[poem_openapi::OpenApi]
impl TodoApi {
#[oai(path = "/todo", method = "post")]
async fn add(&self, todo_add_req: Json<TodoAddReq>) -> TardisApiResult<i32> {
Expand Down
4 changes: 2 additions & 2 deletions examples/reldb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "tardis-example-reldb"
version = "0.1.0"
authors = ["gudaoxuri"]
edition = "2021"
publish = false

[dependencies]
tardis = { path = "../..", features = ["reldb", "test"] }
sea-orm = { version = "0.9", features = ["macros"] }
tardis = { path = "../..", features = ["reldb", "test"] }
1 change: 1 addition & 0 deletions examples/reldb/src/domain/account.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use tardis::basic::dto::TardisContext;
use tardis::db::reldb_client::TardisActiveModel;
use tardis::db::sea_orm;
use tardis::db::sea_orm::*;
use tardis::TardisFuns;

Expand Down
1 change: 1 addition & 0 deletions examples/reldb/src/domain/app.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use tardis::basic::dto::TardisContext;
use tardis::db::reldb_client::TardisActiveModel;
use tardis::db::sea_orm;
use tardis::db::sea_orm::*;
use tardis::TardisFuns;

Expand Down
1 change: 1 addition & 0 deletions examples/reldb/src/domain/app_account_rel.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use tardis::db::sea_orm;
use tardis::db::sea_orm::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
Expand Down
1 change: 1 addition & 0 deletions examples/reldb/src/domain/tenant.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use tardis::basic::dto::TardisContext;
use tardis::db::reldb_client::TardisActiveModel;
use tardis::db::sea_orm;
use tardis::db::sea_orm::*;
use tardis::TardisFuns;

Expand Down
1 change: 1 addition & 0 deletions examples/reldb/src/domain/tenant_conf.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use tardis::basic::dto::TardisContext;
use tardis::db::reldb_client::TardisActiveModel;
use tardis::db::sea_orm;
use tardis::db::sea_orm::*;
use tardis::TardisFuns;

Expand Down
6 changes: 1 addition & 5 deletions examples/todos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ name = "tardis-example-todos"
version = "0.1.0"
authors = ["gudaoxuri"]
edition = "2021"
publish = false

[dependencies]
serde = { version = "1", features = ["derive"] }
# Tardis Functions
tardis = { path = "../..", features = ["web-server", "reldb", "test"] }
# Web server dependencies
poem-openapi = { version = "2" }
# Reldb dependencies
sea-orm = { version = "0.9", features = ["macros"] }

1 change: 1 addition & 0 deletions examples/todos/src/domain/todos.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use tardis::basic::dto::TardisContext;
use tardis::db::reldb_client::TardisActiveModel;
use tardis::db::sea_orm;
use tardis::db::sea_orm::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
Expand Down
12 changes: 7 additions & 5 deletions examples/todos/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@ use serde::{Deserialize, Serialize};

use tardis::basic::error::TardisError;
use tardis::basic::field::TrimString;
use tardis::db::sea_orm;
use tardis::db::sea_orm::sea_query::Query as DbQuery;
use tardis::db::sea_orm::*;
use tardis::web::context_extractor::TardisContextExtractor;
use tardis::web::poem_openapi;
use tardis::web::poem_openapi::param::Query;
use tardis::web::poem_openapi::{param::Path, payload::Json, Object, OpenApi};
use tardis::web::poem_openapi::{param::Path, payload::Json};
use tardis::web::web_resp::{TardisApiResult, Void};
use tardis::web::web_resp::{TardisPage, TardisResp};
use tardis::TardisFuns;

use crate::domain::todos;

#[derive(Object, FromQueryResult, Serialize, Deserialize, Debug)]
#[derive(poem_openapi::Object, sea_orm::FromQueryResult, Serialize, Deserialize, Debug)]
struct TodoDetailResp {
id: i32,
code: String,
description: String,
done: bool,
}

#[derive(Object, Serialize, Deserialize, Debug)]
#[derive(poem_openapi::Object, Serialize, Deserialize, Debug)]
struct TodoAddReq {
#[oai(validator(min_length = "2", max_length = "255"))]
code: TrimString,
Expand All @@ -30,7 +32,7 @@ struct TodoAddReq {
done: bool,
}

#[derive(Object, Serialize, Deserialize, Debug)]
#[derive(poem_openapi::Object, Serialize, Deserialize, Debug)]
struct TodoModifyReq {
#[oai(validator(min_length = "2", max_length = "255"))]
description: Option<String>,
Expand All @@ -39,7 +41,7 @@ struct TodoModifyReq {

pub struct TodoApi;

#[OpenApi(prefix_path = "/todo")]
#[poem_openapi::OpenApi(prefix_path = "/todo")]
impl TodoApi {
// curl -X POST "http://127.0.0.1:8089/todo" \
// -H "Accept: application/json" \
Expand Down
3 changes: 1 addition & 2 deletions examples/web-basic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name = "tardis-example-web-basic"
version = "0.1.0"
authors = ["gudaoxuri"]
edition = "2021"
publish = false

[dependencies]
tardis = { path = "../..", features = ["web-server"] }
poem-openapi = { version = "2" }

4 changes: 2 additions & 2 deletions examples/web-basic/src/processor.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use tardis::basic::error::TardisError;
use tardis::web::poem_openapi;
use tardis::web::poem_openapi::param::Query;
use tardis::web::poem_openapi::OpenApi;
use tardis::web::web_resp::{TardisApiResult, TardisResp};

pub struct Api;

#[OpenApi]
#[poem_openapi::OpenApi]
impl Api {
#[oai(path = "/hello", method = "get")]
async fn index(&self, name: Query<Option<String>>) -> TardisApiResult<String> {
Expand Down
Loading

0 comments on commit 7fd82fd

Please sign in to comment.