update example's dependency versions (#1759)

* version update, all examples marked with #notcomplete does not compile with cargo run

* WIP

* salvo example fixed

* testing, and boost a minor version

* fmt

* build dependency update

* CI

* cleanup

---------

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
This commit is contained in:
darkmmon 2023-07-25 16:12:44 +08:00 committed by GitHub
parent 2eeb93567c
commit 84be56e01a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 70 additions and 63 deletions

View File

@ -245,6 +245,8 @@ jobs:
path: ${{ fromJson(needs.examples-matrix.outputs.path_matrix) }} path: ${{ fromJson(needs.examples-matrix.outputs.path_matrix) }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- if: ${{ contains(matrix.path, 'tonic_example') }}
uses: arduino/setup-protoc@v1
- uses: dtolnay/rust-toolchain@master - uses: dtolnay/rust-toolchain@master
with: with:
toolchain: nightly toolchain: nightly

View File

@ -9,12 +9,12 @@ publish = false
actix-example-service = { path = "../service" } actix-example-service = { path = "../service" }
actix-files = "0.6" actix-files = "0.6"
actix-http = "3" actix-http = "3"
actix-rt = "2.7" actix-rt = "2.8"
actix-service = "2" actix-service = "2"
actix-web = "4" actix-web = "4"
tera = "1.15.0" tera = "1.19.0"
dotenvy = "0.15" dotenvy = "0.15"
listenfd = "0.5" listenfd = "1"
serde = "1" serde = "1"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
entity = { path = "../entity" } entity = { path = "../entity" }

View File

@ -7,15 +7,15 @@ publish = false
[dependencies] [dependencies]
axum-example-service = { path = "../service" } axum-example-service = { path = "../service" }
tokio = { version = "1.23.0", features = ["full"] } tokio = { version = "1.29.0", features = ["full"] }
axum = "0.6.1" axum = "0.6.19"
tower = "0.4.13" tower = "0.4.13"
tower-http = { version = "0.3.5", features = ["fs"] } tower-http = { version = "0.4.3", features = ["fs"] }
tower-cookies = "0.8.0" tower-cookies = "0.9.0"
anyhow = "1.0.66" anyhow = "1.0.71"
dotenvy = "0.15.6" dotenvy = "0.15.7"
serde = "1.0.149" serde = "1.0.175"
serde_json = "1.0.89" serde_json = "1.0.102"
tera = "1.17.1" tera = "1.17.1"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
entity = { path = "../entity" } entity = { path = "../entity" }

View File

@ -53,7 +53,7 @@ async fn start() -> anyhow::Result<()> {
env!("CARGO_MANIFEST_DIR"), env!("CARGO_MANIFEST_DIR"),
"/static" "/static"
))) )))
.handle_error(|error: std::io::Error| async move { .handle_error(|error| async move {
( (
StatusCode::INTERNAL_SERVER_ERROR, StatusCode::INTERNAL_SERVER_ERROR,
format!("Unhandled internal error: {error}"), format!("Unhandled internal error: {error}"),

View File

@ -8,7 +8,7 @@ edition = "2021"
publish = false publish = false
[dependencies] [dependencies]
async-std = { version = "1.9", features = [ "attributes", "tokio1" ] } async-std = { version = "1.12", features = [ "attributes", "tokio1" ] }
sea-orm = { path = "../../", features = [ "sqlx-all", "runtime-async-std-native-tls" ] } sea-orm = { path = "../../", features = [ "sqlx-all", "runtime-async-std-native-tls" ] }
serde_json = { version = "1" } serde_json = { version = "1" }
futures = { version = "0.3" } futures = { version = "0.3" }

View File

@ -7,9 +7,10 @@ publish = false
[dependencies] [dependencies]
graphql-example-service = { path = "../service" } graphql-example-service = { path = "../service" }
tokio = { version = "1.0", features = ["full"] } tokio = { version = "1.29", features = ["full"] }
axum = "0.5.1" axum = "0.6.18"
dotenvy = "0.15.0" axum-macros = "0.3"
async-graphql-axum = "4.0.6" dotenvy = "0.15.7"
async-graphql-axum = "5.0.10"
entity = { path = "../entity" } entity = { path = "../entity" }
migration = { path = "../migration" } migration = { path = "../migration" }

View File

@ -6,17 +6,19 @@ use entity::async_graphql;
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig}; use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
use async_graphql_axum::{GraphQLRequest, GraphQLResponse}; use async_graphql_axum::{GraphQLRequest, GraphQLResponse};
use axum::{ use axum::{
extract::Extension, extract::State,
response::{Html, IntoResponse}, response::{Html, IntoResponse},
routing::get, routing::get,
Router, Router,
}; };
use axum_macros::debug_handler;
use graphql::schema::{build_schema, AppSchema}; use graphql::schema::{build_schema, AppSchema};
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
use dotenvy::dotenv; use dotenvy::dotenv;
async fn graphql_handler(schema: Extension<AppSchema>, req: GraphQLRequest) -> GraphQLResponse { #[debug_handler]
async fn graphql_handler(schema: State<AppSchema>, req: GraphQLRequest) -> GraphQLResponse {
schema.execute(req.into_inner()).await.into() schema.execute(req.into_inner()).await.into()
} }
@ -38,7 +40,7 @@ pub async fn main() {
"/api/graphql", "/api/graphql",
get(graphql_playground).post(graphql_handler), get(graphql_playground).post(graphql_handler),
) )
.layer(Extension(schema)); .with_state(schema);
println!("Playground: http://localhost:3000/api/graphql"); println!("Playground: http://localhost:3000/api/graphql");

View File

@ -12,7 +12,7 @@ path = "src/lib.rs"
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
[dependencies.async-graphql] [dependencies.async-graphql]
version = "4.0.6" version = "5.0.10"
[dependencies.sea-orm] [dependencies.sea-orm]
path = "../../../" # remove this line in your own project path = "../../../" # remove this line in your own project

View File

@ -6,14 +6,14 @@ publish = false
[dependencies] [dependencies]
jsonrpsee-example-service = { path = "../service" } jsonrpsee-example-service = { path = "../service" }
jsonrpsee = { version = "0.8.0", features = ["full"] } jsonrpsee = { version = "0.18.2", features = ["full"] }
jsonrpsee-core = "0.9.0" jsonrpsee-core = "0.18.2"
tokio = { version = "1.8.0", features = ["full"] } tokio = { version = "1.29.1", features = ["full"] }
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
dotenvy = "0.15" dotenvy = "0.15"
entity = { path = "../entity" } entity = { path = "../entity" }
migration = { path = "../migration" } migration = { path = "../migration" }
anyhow = "1.0.52" anyhow = "1.0.71"
async-trait = "0.1.52" async-trait = "0.1.71"
log = { version = "0.4", features = ["std"] } log = { version = "0.4", features = ["std"] }
simplelog = "0.12" simplelog = "0.12"

View File

@ -1,11 +1,10 @@
use std::env; use std::env;
use anyhow::anyhow;
use entity::post; use entity::post;
use jsonrpsee::core::{async_trait, RpcResult}; use jsonrpsee::core::{async_trait, RpcResult};
use jsonrpsee::http_server::HttpServerBuilder;
use jsonrpsee::proc_macros::rpc; use jsonrpsee::proc_macros::rpc;
use jsonrpsee::types::error::CallError; use jsonrpsee::server::ServerBuilder;
use jsonrpsee::types::error::ErrorObjectOwned;
use jsonrpsee_example_service::sea_orm::{Database, DatabaseConnection}; use jsonrpsee_example_service::sea_orm::{Database, DatabaseConnection};
use jsonrpsee_example_service::{Mutation, Query}; use jsonrpsee_example_service::{Mutation, Query};
use log::info; use log::info;
@ -14,7 +13,7 @@ use simplelog::*;
use std::fmt::Display; use std::fmt::Display;
use std::net::SocketAddr; use std::net::SocketAddr;
use tokio::signal::ctrl_c; use tokio::signal::ctrl_c;
use tokio::signal::unix::{signal, SignalKind}; // use tokio::signal::unix::{signal, SignalKind};
const DEFAULT_POSTS_PER_PAGE: u64 = 5; const DEFAULT_POSTS_PER_PAGE: u64 = 5;
@ -88,7 +87,9 @@ where
E: Display, E: Display,
{ {
fn internal_call_error(self) -> RpcResult<T> { fn internal_call_error(self) -> RpcResult<T> {
self.map_err(|e| jsonrpsee::core::Error::Call(CallError::Failed(anyhow!("{}", e)))) // Err(ErrorObjectOwned::owned(1, "c", None::<()>))
// self.map_err(|e| jsonrpsee::core::Error::Call(CallError::Failed(anyhow!("{}", e))))
self.map_err(|e| ErrorObjectOwned::owned(1, format!("{}", e), None::<()>))
} }
} }
@ -112,8 +113,9 @@ async fn start() -> std::io::Result<()> {
let conn = Database::connect(&db_url).await.unwrap(); let conn = Database::connect(&db_url).await.unwrap();
Migrator::up(&conn, None).await.unwrap(); Migrator::up(&conn, None).await.unwrap();
let server = HttpServerBuilder::default() let server = ServerBuilder::default()
.build(server_url.parse::<SocketAddr>().unwrap()) .build(server_url.parse::<SocketAddr>().unwrap())
.await
.unwrap(); .unwrap();
let rpc_impl = PpcImpl { conn }; let rpc_impl = PpcImpl { conn };
@ -121,12 +123,12 @@ async fn start() -> std::io::Result<()> {
let handle = server.start(rpc_impl.into_rpc()).unwrap(); let handle = server.start(rpc_impl.into_rpc()).unwrap();
info!("starting listening {}", server_addr); info!("starting listening {}", server_addr);
let mut sig_int = signal(SignalKind::interrupt()).unwrap(); // let mut sig_int = signal(SignalKind::interrupt()).unwrap();
let mut sig_term = signal(SignalKind::terminate()).unwrap(); // let mut sig_term = signal(SignalKind::terminate()).unwrap();
tokio::select! { tokio::select! {
_ = sig_int.recv() => info!("receive SIGINT"), // _ = sig_int.recv() => info!("receive SIGINT"),
_ = sig_term.recv() => info!("receive SIGTERM"), // _ = sig_term.recv() => info!("receive SIGTERM"),
_ = ctrl_c() => info!("receive Ctrl C"), _ = ctrl_c() => info!("receive Ctrl C"),
} }
handle.stop().unwrap(); handle.stop().unwrap();

View File

@ -5,11 +5,11 @@ edition = "2021"
[dependencies] [dependencies]
poem-example-service = { path = "../service" } poem-example-service = { path = "../service" }
tokio = { version = "1.15.0", features = ["macros", "rt-multi-thread"] } tokio = { version = "1.29.0", features = ["macros", "rt-multi-thread"] }
poem = { version = "1.2.33", features = ["static-files"] } poem = { version = "1.3.56", features = ["static-files"] }
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
tera = "1.8.0" tera = "1.19.0"
dotenvy = "0.15" dotenvy = "0.15"
entity = { path = "../entity" } entity = { path = "../entity" }
migration = { path = "../migration" } migration = { path = "../migration" }

View File

@ -20,7 +20,7 @@ rocket_dyn_templates = { version = "0.1.0-rc.1", features = [
serde_json = { version = "1" } serde_json = { version = "1" }
entity = { path = "../entity" } entity = { path = "../entity" }
migration = { path = "../migration" } migration = { path = "../migration" }
tokio = "1.20.0" tokio = "1.29.0"
[dependencies.sea-orm-rocket] [dependencies.sea-orm-rocket]
path = "../../../sea-orm-rocket/lib" # remove this line in your own project and uncomment the following line path = "../../../sea-orm-rocket/lib" # remove this line in your own project and uncomment the following line

View File

@ -5,11 +5,11 @@ edition = "2021"
[dependencies] [dependencies]
salvo-example-service = { path = "../service" } salvo-example-service = { path = "../service" }
tokio = { version = "1.15.0", features = ["macros", "rt-multi-thread"] } tokio = { version = "1.29.0", features = ["macros", "rt-multi-thread"] }
salvo = { version = "0.27", features = ["affix", "serve-static"] } salvo = { version = "0.49", features = ["affix", "serve-static"] }
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
tera = "1.8.0" tera = "1.19.0"
dotenvy = "0.15" dotenvy = "0.15"
entity = { path = "../entity" } entity = { path = "../entity" }
migration = { path = "../migration" } migration = { path = "../migration" }

View File

@ -2,10 +2,8 @@ use std::env;
use entity::post; use entity::post;
use migration::{Migrator, MigratorTrait}; use migration::{Migrator, MigratorTrait};
use salvo::extra::affix; use salvo::affix;
use salvo::extra::serve_static::DirHandler;
use salvo::prelude::*; use salvo::prelude::*;
use salvo::writer::Text;
use salvo_example_service::{ use salvo_example_service::{
sea_orm::{Database, DatabaseConnection}, sea_orm::{Database, DatabaseConnection},
Mutation, Query, Mutation, Query,
@ -29,7 +27,7 @@ async fn create(req: &mut Request, depot: &mut Depot, res: &mut Response) -> Res
let conn = &state.conn; let conn = &state.conn;
let form = req let form = req
.extract_form::<post::Model>() .parse_form::<post::Model>()
.await .await
.map_err(|_| StatusError::bad_request())?; .map_err(|_| StatusError::bad_request())?;
@ -37,7 +35,7 @@ async fn create(req: &mut Request, depot: &mut Depot, res: &mut Response) -> Res
.await .await
.map_err(|_| StatusError::internal_server_error())?; .map_err(|_| StatusError::internal_server_error())?;
res.redirect_found("/"); Redirect::found("/").render(res);
Ok(()) Ok(())
} }
@ -114,7 +112,7 @@ async fn update(req: &mut Request, depot: &mut Depot, res: &mut Response) -> Res
let conn = &state.conn; let conn = &state.conn;
let id = req.param::<i32>("id").unwrap_or_default(); let id = req.param::<i32>("id").unwrap_or_default();
let form = req let form = req
.extract_form::<post::Model>() .parse_form::<post::Model>()
.await .await
.map_err(|_| StatusError::bad_request())?; .map_err(|_| StatusError::bad_request())?;
@ -122,7 +120,7 @@ async fn update(req: &mut Request, depot: &mut Depot, res: &mut Response) -> Res
.await .await
.map_err(|_| StatusError::internal_server_error())?; .map_err(|_| StatusError::internal_server_error())?;
res.redirect_found("/"); Redirect::found("/").render(res);
Ok(()) Ok(())
} }
@ -138,7 +136,7 @@ async fn delete(req: &mut Request, depot: &mut Depot, res: &mut Response) -> Res
.await .await
.map_err(|_| StatusError::internal_server_error())?; .map_err(|_| StatusError::internal_server_error())?;
res.redirect_found("/"); Redirect::found("/").render(res);
Ok(()) Ok(())
} }
@ -170,13 +168,13 @@ pub async fn main() {
.push(Router::with_path("<id>").get(edit).post(update)) .push(Router::with_path("<id>").get(edit).post(update))
.push(Router::with_path("delete/<id>").post(delete)) .push(Router::with_path("delete/<id>").post(delete))
.push( .push(
Router::with_path("static/<**>").get(DirHandler::new(concat!( Router::with_path("static/<**>").get(salvo::prelude::StaticDir::new(concat!(
env!("CARGO_MANIFEST_DIR"), env!("CARGO_MANIFEST_DIR"),
"/static" "/static"
))), ))),
); );
Server::new(TcpListener::bind(&format!("{host}:{port}"))) Server::new(TcpListener::bind(TcpListener::new(format!("{host}:{port}"))).await)
.serve(router) .serve(router)
.await; .await;
} }

View File

@ -10,6 +10,7 @@ path = "src/lib.rs"
[dependencies] [dependencies]
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
salvo = { version = "0.49" }
[dependencies.sea-orm] [dependencies.sea-orm]
path = "../../../" # remove this line in your own project path = "../../../" # remove this line in your own project

View File

@ -1,7 +1,8 @@
use salvo::prelude::Extractible;
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Extractible, Deserialize, Serialize)]
#[sea_orm(table_name = "posts")] #[sea_orm(table_name = "posts")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -11,8 +11,8 @@ members = [".", "api", "service", "entity", "migration"]
[dependencies] [dependencies]
tonic-example-api = { path = "api" } tonic-example-api = { path = "api" }
tonic = "0.7" tonic = "0.9.2"
tokio = { version = "1.17", features = ["macros", "rt-multi-thread", "full"] } tokio = { version = "1.29", features = ["macros", "rt-multi-thread", "full"] }
[[bin]] [[bin]]
name = "server" name = "server"

View File

@ -6,15 +6,15 @@ publish = false
[dependencies] [dependencies]
tonic-example-service = { path = "../service" } tonic-example-service = { path = "../service" }
tonic = "0.7" tonic = "0.9.2"
tokio = { version = "1.17", features = ["macros", "rt-multi-thread", "full"] } tokio = { version = "1.29", features = ["macros", "rt-multi-thread", "full"] }
entity = { path = "../entity" } entity = { path = "../entity" }
migration = { path = "../migration" } migration = { path = "../migration" }
prost = "0.10.0" prost = "0.11.9"
serde = "1.0" serde = "1.0"
[lib] [lib]
path = "./src/lib.rs" path = "./src/lib.rs"
[build-dependencies] [build-dependencies]
tonic-build = "0.7" tonic-build = "0.9.2"