Skip to content

Commit

Permalink
Merge pull request #143 from ideal-world/update-dependencies
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
4t145 authored Oct 16, 2024
2 parents 03ef942 + 9a25ef9 commit 4cae0aa
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
token: ${{secrets.CODECOV_TOKEN}}

- name: Archive code coverage results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: cobertura.xml
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ codegen-units = 1
opt-level = "z"

[workspace.package]
version = "0.1.0-rc.16"
version = "0.1.0-rc.17"
authors = ["gudaoxuri <[email protected]>"]
description = "Elegant, clean Rust development framework"
keywords = ["http", "database", "web", "redis", "mq"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct Model {
pub number64: i64,
pub number_f32: f32,
pub number_f64: f64,
pub number_u8: Vec<u8>,
pub be_var_binary: Vec<u8>,
pub can_bool: bool,
#[index(full_text, index_id = "index_id_3")]
pub can_be_null: Option<String>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct Model {
pub number64: i64,
pub number_f32: f32,
pub number_f64: f64,
pub number_u8: Vec<u8>,
pub be_var_binary: Vec<u8>,
pub can_bool: bool,
pub can_be_null: Option<String>,
#[tardis_entity(custom_type = "char", custom_len = "50")]
Expand Down
22 changes: 10 additions & 12 deletions tardis-macros/src/tardis_create_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ fn create_single_col_token_statement(field: CreateTableMeta) -> Result<TokenStre
));
}
if attribute.is_empty() {
Ok(quote! {col(&mut ::tardis::db::sea_orm::sea_query::ColumnDef::new_with_type(Column::#ident,#col_type))})
Ok(quote! {col(::tardis::db::sea_orm::sea_query::ColumnDef::new_with_type(Column::#ident,#col_type))})
} else {
Ok(quote! {col(&mut ::tardis::db::sea_orm::sea_query::ColumnDef::new_with_type(Column::#ident,#col_type).#attribute)})
Ok(quote! {col(::tardis::db::sea_orm::sea_query::ColumnDef::new_with_type(Column::#ident,#col_type).#attribute)})
}
} else {
Ok(quote! {})
Expand All @@ -246,7 +246,7 @@ fn map_rust_ty_custom_ty(ident: &Ident, segments_type: Option<&str>) -> Result<S
"i8" => "tiny_integer",
"u8" => {
if let Some("Vec") = segments_type {
"binary"
"var_binary"
} else if cfg!(feature = "reldb-postgres") {
return Err(Error::new(
span,
Expand Down Expand Up @@ -309,7 +309,7 @@ fn map_rust_ty_custom_ty(ident: &Ident, segments_type: Option<&str>) -> Result<S
"Value" | "Json" | _ => "Json",
};
let result = if let Some("Vec") = segments_type {
if custom_ty != "binary" {
if custom_ty != "var_binary" && custom_ty != "binary" {
format!("array.{custom_ty}")
} else {
custom_ty.to_string()
Expand Down Expand Up @@ -337,9 +337,9 @@ fn map_custom_type_to_sea_type(custom_column_type: &str, custom_len: Vec<u32>, s
}
"String" | "string" => {
if let Some(len) = custom_len.first() {
quote!(::tardis::db::sea_orm::sea_query::ColumnType::String(Some(#len)))
quote!(::tardis::db::sea_orm::sea_query::ColumnType::String(::tardis::db::sea_orm::sea_query::StringLen::N(#len)))
} else {
quote!(::tardis::db::sea_orm::sea_query::ColumnType::String(None))
quote!(::tardis::db::sea_orm::sea_query::ColumnType::String(::tardis::db::sea_orm::sea_query::StringLen::None))
}
}
"Text" | "text" => {
Expand Down Expand Up @@ -399,18 +399,16 @@ fn map_custom_type_to_sea_type(custom_column_type: &str, custom_len: Vec<u32>, s
}
"Binary" | "binary" => {
if let Some(len) = custom_len.first() {
quote!(::tardis::db::sea_orm::sea_query::ColumnType::Binary(::tardis::db::sea_orm::sea_query::BlobSize::Blob(
Some(#len)
)))
quote!(::tardis::db::sea_orm::sea_query::ColumnType::Binary(#len))
} else {
quote!(::tardis::db::sea_orm::sea_query::ColumnType::Binary(::tardis::db::sea_orm::sea_query::BlobSize::Blob(None)))
return Err(Error::new(span, "column_type:binary must have custom_len!".to_string()));
}
}
"VarBinary" | "var_binary" => {
if let Some(len) = custom_len.first() {
quote!(::tardis::db::sea_orm::sea_query::ColumnType::VarBinary(#len))
quote!(::tardis::db::sea_orm::sea_query::ColumnType::VarBinary(::tardis::db::sea_orm::sea_query::StringLen::N(#len)))
} else {
return Err(Error::new(span, "column_type:var_binary must have custom_len!".to_string()));
quote!(::tardis::db::sea_orm::sea_query::ColumnType::VarBinary(::tardis::db::sea_orm::sea_query::StringLen::None))
}
}
"Bit" | "bit" => {
Expand Down
46 changes: 21 additions & 25 deletions tardis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ cache = ["futures-util", "redis", "deadpool-redis"]
mq = ["futures-util", "lapin", "amq-protocol-types", "async-global-executor"]
mail = ["lettre"]
os = ["async-trait", "anyhow", "rust-s3", "urlencoding"]
k8s = ["future", "kube", "k8s-openapi"]
fs = ["tokio/fs", "tokio/io-util"]
process = ["tokio/process"]
test = ["testcontainers", "testcontainers-modules"]
Expand All @@ -61,7 +60,7 @@ tracing = [
"opentelemetry-otlp",
"opentelemetry_sdk",
"opentelemetry-http",
"poem?/opentelemetry"
"poem?/opentelemetry",
]
tokio-console = ["console-subscriber"]
tracing-appender = ["dep:tracing-appender"]
Expand All @@ -74,9 +73,9 @@ opentelemetry-http = ["dep:opentelemetry-http"]
# Basic
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1" }
derive_more = { version = "0.99" }
derive_more = { version = "1", features = ["full"] }
nanoid = { version = "0.4" }
base64 = { version = "0.21" }
base64 = { version = "0.22" }
hex = { version = "0.4" }
lazy_static = { version = "1.4" }
rand = { version = "0.8" }
Expand All @@ -86,9 +85,9 @@ config = { version = "0.13" }
regex = { version = "1.5" }
url = { version = "2.2", features = ["serde"] }
lru = { version = "0.12.0" }
typed-builder = { version = "0.18" }
typed-builder = { version = "0.20" }
paste = { version = "1.0" }
urlencoding = { version = "2" , optional = true }
urlencoding = { version = "2", optional = true }
# Tokio
tokio = { version = "1", features = [
"macros",
Expand All @@ -97,14 +96,14 @@ tokio = { version = "1", features = [
"time",
"sync",
] }
tokio-util = { version = "0.7.10" }
tokio-util = { version = "0.7.12" }
# Tardis Macros
tardis-macros = { version = "0.1.0-rc.14", optional = true }
tardis-macros = { workspace = true, optional = true }
# Log
tracing = { version = "0.1" }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tracing-appender = { version = "0.2", optional = true }
console-subscriber = { version = "0.2", optional = true }
console-subscriber = { version = "0.4", optional = true }
# Tracing
tracing-opentelemetry = { version = "0.25", optional = true }
opentelemetry = { version = "0.24", default-features = false, features = [
Expand All @@ -120,6 +119,8 @@ opentelemetry-otlp = { version = "0.17", features = [
"http-proto",
"tls",
], optional = true }
opentelemetry-http = { version = "0.13", optional = true }

# TLS
native-tls = { version = "0.2", optional = true }

Expand Down Expand Up @@ -161,7 +162,7 @@ futures-util = { version = "0.3", optional = true }
async-trait = { version = "0.1", optional = true }

# RelDB
sea-orm = { version = "0.12", features = [
sea-orm = { version = "1", features = [
"macros",
"runtime-tokio-native-tls",
"with-chrono",
Expand All @@ -187,26 +188,26 @@ poem = { version = "3", features = [
"tempfile",
"session",
], optional = true }
poem-grpc = { version = "0.4", optional = true }
poem-grpc = { version = "0.5", optional = true }

# Web Client
reqwest = { version = "0.12", features = [
"json",
"multipart",
"stream"
"stream",
], optional = true }

# Websocket Client
tokio-tungstenite = { version = "0.21", features = [
tokio-tungstenite = { version = "0.24", features = [
"native-tls",
], optional = true }

# Redis
redis = { version = "0.24", features = [
redis = { version = "0.27", features = [
"tokio-comp",
"tokio-native-tls-comp",
], optional = true }
deadpool-redis = { version = "0.14", optional = true }
deadpool-redis = { version = "0.18", optional = true }

# Rabbit
lapin = { version = "2", optional = true }
Expand All @@ -223,16 +224,12 @@ lettre = { version = "0.11", features = [

# Object Storage
# rust-s3 = { version = "0.33", optional = true }
rust-s3 = { version = "0.35.0-alpha.3", optional = true, features = ["no-verify-ssl"] }
rust-s3 = { version = "0.35.1", optional = true, features = [
"no-verify-ssl",
] }
# rust-s3 = { path = "../../rust-s3/s3", optional = true }
anyhow = { version = "1.0", optional = true }

# K8s
kube = { version = "^0.87", features = ["runtime"], optional = true }
# temporarily fix https://github.com/kube-rs/kube/issues/1486
json-patch = "=1.2.0"
k8s-openapi = { version = "^0.20", features = ["earliest"], optional = true }

# Test
# update this may cause break changes
testcontainers = { version = "0.15", optional = true }
Expand All @@ -243,7 +240,6 @@ testcontainers-modules = { version = "0.3", features = [

# Debug
git-version = { version = "0.3.9", optional = true }
opentelemetry-http = { version = "0.12.0", features = ["tokio"], optional = true }
http = "1.1.0"
crossbeam = "0.8.4"

Expand All @@ -257,8 +253,8 @@ tokio = { version = "1", features = [
"process",
] }
criterion = { version = "0.5" }
poem-grpc-build = "0.4"
prost = "0.13.1"
poem-grpc-build = "0.5"
prost = "0.13.3"
strip-ansi-escapes = "0.2.0"
portpicker = "0.1.1"
# macros
Expand Down
10 changes: 0 additions & 10 deletions tardis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
* ``tracing`` open telemetry support
* ``tokio-console`` console subscriber layer supported by [tokio-console](https://github.com/tokio-rs/console)
* ``tracing-appender`` write log into file periodically.
* ``cluster`` work with tardis cluster
* ``k8s`` k8s support for cluster
* ``build-info`` get build info like package version or git version

## 🚀 Quick start
Expand Down Expand Up @@ -117,14 +115,6 @@ async fn main() -> TardisResult<()> {
Ok(())
}
```
### Run with cluster mode
You can enable cluster mode when it has multi nodes, especially when it comes to k8s.
```toml
[fw.cluster]
watch_kind = "k8s"
k8s_svc = "my-service"
k8s_ns = "my-namespace"
```

### Dependencies

Expand Down
7 changes: 0 additions & 7 deletions tardis/src/basic/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,3 @@ impl From<opentelemetry::trace::TraceError> for TardisError {
TardisError::internal_error(&format!("[Tardis.Basic] {error}"), "")
}
}

#[cfg(feature = "k8s")]
impl From<kube::Error> for TardisError {
fn from(error: kube::Error) -> Self {
TardisError::internal_error(&format!("[Tardis.Basic] {error}"), "")
}
}
4 changes: 2 additions & 2 deletions tardis/src/config/config_nacos/nacos_client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, fmt::Display, io::Read, sync::Arc};
use std::{collections::HashMap, io::Read, sync::Arc};

use derive_more::Display;
// use futures::TryFutureExt;
Expand Down Expand Up @@ -188,7 +188,7 @@ impl NacosClient {
async fn listen_config_inner<T: Serialize>(&self, params: &T) -> Result<reqwest::Response, NacosClientError> {
let resp = self
.reqwest_client
.post(&format!("{}/v1/cs/configs/listener", self.base_url))
.post(format!("{}/v1/cs/configs/listener", self.base_url))
// refer: https://nacos.io/zh-cn/docs/open-api.html
// doc says it's `pulling` instead of `polling`
.header("Long-Pulling-Timeout", self.poll_period.as_millis().to_string())
Expand Down
4 changes: 2 additions & 2 deletions tardis/src/db/reldb_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl TardisRelDBClient {
raw_opt = raw_opt.log_statements(opt.get_sqlx_logging_level());
}
let result = opt
.pool_options::<sqlx::MySql>()
.sqlx_pool_options::<sqlx::MySql>()
.after_connect(move |conn, _| {
let timezone = timezone.clone();
Box::pin(async move {
Expand Down Expand Up @@ -207,7 +207,7 @@ impl TardisRelDBClient {
raw_opt = raw_opt.disable_statement_logging();
}
let result = opt
.pool_options::<sqlx::Postgres>()
.sqlx_pool_options::<sqlx::Postgres>()
.after_connect(move |conn, _| {
let timezone = timezone.clone();
Box::pin(async move {
Expand Down
4 changes: 2 additions & 2 deletions tardis/src/os/os_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct TardisOSClient {
struct TardisOSS3Client {
region: Region,
credentials: Credentials,
default_bucket: Option<Bucket>,
default_bucket: Option<Box<Bucket>>,
}

#[async_trait::async_trait]
Expand Down Expand Up @@ -372,7 +372,7 @@ impl TardisOSOperations for TardisOSS3Client {
}

impl TardisOSS3Client {
fn get_bucket(&self, bucket_name: Option<&str>) -> TardisResult<Bucket> {
fn get_bucket(&self, bucket_name: Option<&str>) -> TardisResult<Box<Bucket>> {
if let Some(bucket_name) = bucket_name {
Ok(*Bucket::new(bucket_name, self.region.clone(), self.credentials.clone())?.with_path_style())
} else {
Expand Down
2 changes: 1 addition & 1 deletion tardis/src/utils/tardis_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct TardisComponentInner<T> {
inner: RwLock<Arc<T>>,
}

impl<T: ?Sized + Default> Deref for TardisComponent<T> {
impl<T: Default> Deref for TardisComponent<T> {
type Target = TardisComponentInner<T>;
fn deref(&self) -> &Self::Target {
self.0.get_or_init(Default::default)
Expand Down
4 changes: 2 additions & 2 deletions tardis/src/web/ws_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ impl TardisWSClient {
url.port().unwrap_or(0)
);
let connect = if url.scheme() != "wss" {
tokio_tungstenite::connect_async(url.clone()).await
tokio_tungstenite::connect_async(url.to_string()).await
} else {
tokio_tungstenite::connect_async_tls_with_config(
url.clone(),
url.to_string(),
None,
false,
Some(Connector::NativeTls(TlsConnector::builder().danger_accept_invalid_certs(true).build().map_err(|e| {
Expand Down
12 changes: 6 additions & 6 deletions tardis/tests/macros_test_all.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// #[test]
// fn test_all() {
// let t = trybuild::TestCases::new();
// t.pass("tests/macros_tests/pass_cases/*.rs");
// t.compile_fail("tests/macros_tests/fail_cases/*.rs");
// }
#[test]
fn test_all() {
let t = trybuild::TestCases::new();
t.pass("tests/macros_tests/pass_cases/*.rs");
// t.compile_fail("tests/macros_tests/fail_cases/*.rs");
}
2 changes: 1 addition & 1 deletion tardis/tests/macros_tests/pass_cases/auto_fill_ctx_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use tardis::{TardisCreateEntity, TardisEmptyBehavior, TardisEmptyRelation};
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[fill_ctx(own_paths)]
#[fill_ctx(fill = "own_paths")]
pub auto_fill_ctx: String,
}

Expand Down
Loading

0 comments on commit 4cae0aa

Please sign in to comment.