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:
parent
2eeb93567c
commit
84be56e01a
2
.github/workflows/rust.yml
vendored
2
.github/workflows/rust.yml
vendored
@ -245,6 +245,8 @@ jobs:
|
||||
path: ${{ fromJson(needs.examples-matrix.outputs.path_matrix) }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- if: ${{ contains(matrix.path, 'tonic_example') }}
|
||||
uses: arduino/setup-protoc@v1
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: nightly
|
||||
|
@ -9,12 +9,12 @@ publish = false
|
||||
actix-example-service = { path = "../service" }
|
||||
actix-files = "0.6"
|
||||
actix-http = "3"
|
||||
actix-rt = "2.7"
|
||||
actix-rt = "2.8"
|
||||
actix-service = "2"
|
||||
actix-web = "4"
|
||||
tera = "1.15.0"
|
||||
tera = "1.19.0"
|
||||
dotenvy = "0.15"
|
||||
listenfd = "0.5"
|
||||
listenfd = "1"
|
||||
serde = "1"
|
||||
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
||||
entity = { path = "../entity" }
|
||||
|
@ -7,15 +7,15 @@ publish = false
|
||||
|
||||
[dependencies]
|
||||
axum-example-service = { path = "../service" }
|
||||
tokio = { version = "1.23.0", features = ["full"] }
|
||||
axum = "0.6.1"
|
||||
tokio = { version = "1.29.0", features = ["full"] }
|
||||
axum = "0.6.19"
|
||||
tower = "0.4.13"
|
||||
tower-http = { version = "0.3.5", features = ["fs"] }
|
||||
tower-cookies = "0.8.0"
|
||||
anyhow = "1.0.66"
|
||||
dotenvy = "0.15.6"
|
||||
serde = "1.0.149"
|
||||
serde_json = "1.0.89"
|
||||
tower-http = { version = "0.4.3", features = ["fs"] }
|
||||
tower-cookies = "0.9.0"
|
||||
anyhow = "1.0.71"
|
||||
dotenvy = "0.15.7"
|
||||
serde = "1.0.175"
|
||||
serde_json = "1.0.102"
|
||||
tera = "1.17.1"
|
||||
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
||||
entity = { path = "../entity" }
|
||||
|
@ -53,7 +53,7 @@ async fn start() -> anyhow::Result<()> {
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/static"
|
||||
)))
|
||||
.handle_error(|error: std::io::Error| async move {
|
||||
.handle_error(|error| async move {
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
format!("Unhandled internal error: {error}"),
|
||||
|
@ -8,7 +8,7 @@ edition = "2021"
|
||||
publish = false
|
||||
|
||||
[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" ] }
|
||||
serde_json = { version = "1" }
|
||||
futures = { version = "0.3" }
|
||||
|
@ -7,9 +7,10 @@ publish = false
|
||||
|
||||
[dependencies]
|
||||
graphql-example-service = { path = "../service" }
|
||||
tokio = { version = "1.0", features = ["full"] }
|
||||
axum = "0.5.1"
|
||||
dotenvy = "0.15.0"
|
||||
async-graphql-axum = "4.0.6"
|
||||
tokio = { version = "1.29", features = ["full"] }
|
||||
axum = "0.6.18"
|
||||
axum-macros = "0.3"
|
||||
dotenvy = "0.15.7"
|
||||
async-graphql-axum = "5.0.10"
|
||||
entity = { path = "../entity" }
|
||||
migration = { path = "../migration" }
|
@ -6,17 +6,19 @@ use entity::async_graphql;
|
||||
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
|
||||
use async_graphql_axum::{GraphQLRequest, GraphQLResponse};
|
||||
use axum::{
|
||||
extract::Extension,
|
||||
extract::State,
|
||||
response::{Html, IntoResponse},
|
||||
routing::get,
|
||||
Router,
|
||||
};
|
||||
use axum_macros::debug_handler;
|
||||
use graphql::schema::{build_schema, AppSchema};
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
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()
|
||||
}
|
||||
|
||||
@ -38,7 +40,7 @@ pub async fn main() {
|
||||
"/api/graphql",
|
||||
get(graphql_playground).post(graphql_handler),
|
||||
)
|
||||
.layer(Extension(schema));
|
||||
.with_state(schema);
|
||||
|
||||
println!("Playground: http://localhost:3000/api/graphql");
|
||||
|
||||
|
@ -12,7 +12,7 @@ path = "src/lib.rs"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
|
||||
[dependencies.async-graphql]
|
||||
version = "4.0.6"
|
||||
version = "5.0.10"
|
||||
|
||||
[dependencies.sea-orm]
|
||||
path = "../../../" # remove this line in your own project
|
||||
|
@ -6,14 +6,14 @@ publish = false
|
||||
|
||||
[dependencies]
|
||||
jsonrpsee-example-service = { path = "../service" }
|
||||
jsonrpsee = { version = "0.8.0", features = ["full"] }
|
||||
jsonrpsee-core = "0.9.0"
|
||||
tokio = { version = "1.8.0", features = ["full"] }
|
||||
jsonrpsee = { version = "0.18.2", features = ["full"] }
|
||||
jsonrpsee-core = "0.18.2"
|
||||
tokio = { version = "1.29.1", features = ["full"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
dotenvy = "0.15"
|
||||
entity = { path = "../entity" }
|
||||
migration = { path = "../migration" }
|
||||
anyhow = "1.0.52"
|
||||
async-trait = "0.1.52"
|
||||
anyhow = "1.0.71"
|
||||
async-trait = "0.1.71"
|
||||
log = { version = "0.4", features = ["std"] }
|
||||
simplelog = "0.12"
|
||||
|
@ -1,11 +1,10 @@
|
||||
use std::env;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use entity::post;
|
||||
use jsonrpsee::core::{async_trait, RpcResult};
|
||||
use jsonrpsee::http_server::HttpServerBuilder;
|
||||
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::{Mutation, Query};
|
||||
use log::info;
|
||||
@ -14,7 +13,7 @@ use simplelog::*;
|
||||
use std::fmt::Display;
|
||||
use std::net::SocketAddr;
|
||||
use tokio::signal::ctrl_c;
|
||||
use tokio::signal::unix::{signal, SignalKind};
|
||||
// use tokio::signal::unix::{signal, SignalKind};
|
||||
|
||||
const DEFAULT_POSTS_PER_PAGE: u64 = 5;
|
||||
|
||||
@ -88,7 +87,9 @@ where
|
||||
E: Display,
|
||||
{
|
||||
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();
|
||||
Migrator::up(&conn, None).await.unwrap();
|
||||
|
||||
let server = HttpServerBuilder::default()
|
||||
let server = ServerBuilder::default()
|
||||
.build(server_url.parse::<SocketAddr>().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let rpc_impl = PpcImpl { conn };
|
||||
@ -121,12 +123,12 @@ async fn start() -> std::io::Result<()> {
|
||||
let handle = server.start(rpc_impl.into_rpc()).unwrap();
|
||||
|
||||
info!("starting listening {}", server_addr);
|
||||
let mut sig_int = signal(SignalKind::interrupt()).unwrap();
|
||||
let mut sig_term = signal(SignalKind::terminate()).unwrap();
|
||||
// let mut sig_int = signal(SignalKind::interrupt()).unwrap();
|
||||
// let mut sig_term = signal(SignalKind::terminate()).unwrap();
|
||||
|
||||
tokio::select! {
|
||||
_ = sig_int.recv() => info!("receive SIGINT"),
|
||||
_ = sig_term.recv() => info!("receive SIGTERM"),
|
||||
// _ = sig_int.recv() => info!("receive SIGINT"),
|
||||
// _ = sig_term.recv() => info!("receive SIGTERM"),
|
||||
_ = ctrl_c() => info!("receive Ctrl C"),
|
||||
}
|
||||
handle.stop().unwrap();
|
||||
|
@ -5,11 +5,11 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
poem-example-service = { path = "../service" }
|
||||
tokio = { version = "1.15.0", features = ["macros", "rt-multi-thread"] }
|
||||
poem = { version = "1.2.33", features = ["static-files"] }
|
||||
tokio = { version = "1.29.0", features = ["macros", "rt-multi-thread"] }
|
||||
poem = { version = "1.3.56", features = ["static-files"] }
|
||||
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
tera = "1.8.0"
|
||||
tera = "1.19.0"
|
||||
dotenvy = "0.15"
|
||||
entity = { path = "../entity" }
|
||||
migration = { path = "../migration" }
|
||||
|
@ -20,7 +20,7 @@ rocket_dyn_templates = { version = "0.1.0-rc.1", features = [
|
||||
serde_json = { version = "1" }
|
||||
entity = { path = "../entity" }
|
||||
migration = { path = "../migration" }
|
||||
tokio = "1.20.0"
|
||||
tokio = "1.29.0"
|
||||
|
||||
[dependencies.sea-orm-rocket]
|
||||
path = "../../../sea-orm-rocket/lib" # remove this line in your own project and uncomment the following line
|
||||
|
@ -5,11 +5,11 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
salvo-example-service = { path = "../service" }
|
||||
tokio = { version = "1.15.0", features = ["macros", "rt-multi-thread"] }
|
||||
salvo = { version = "0.27", features = ["affix", "serve-static"] }
|
||||
tokio = { version = "1.29.0", features = ["macros", "rt-multi-thread"] }
|
||||
salvo = { version = "0.49", features = ["affix", "serve-static"] }
|
||||
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
tera = "1.8.0"
|
||||
tera = "1.19.0"
|
||||
dotenvy = "0.15"
|
||||
entity = { path = "../entity" }
|
||||
migration = { path = "../migration" }
|
@ -2,10 +2,8 @@ use std::env;
|
||||
|
||||
use entity::post;
|
||||
use migration::{Migrator, MigratorTrait};
|
||||
use salvo::extra::affix;
|
||||
use salvo::extra::serve_static::DirHandler;
|
||||
use salvo::affix;
|
||||
use salvo::prelude::*;
|
||||
use salvo::writer::Text;
|
||||
use salvo_example_service::{
|
||||
sea_orm::{Database, DatabaseConnection},
|
||||
Mutation, Query,
|
||||
@ -29,7 +27,7 @@ async fn create(req: &mut Request, depot: &mut Depot, res: &mut Response) -> Res
|
||||
let conn = &state.conn;
|
||||
|
||||
let form = req
|
||||
.extract_form::<post::Model>()
|
||||
.parse_form::<post::Model>()
|
||||
.await
|
||||
.map_err(|_| StatusError::bad_request())?;
|
||||
|
||||
@ -37,7 +35,7 @@ async fn create(req: &mut Request, depot: &mut Depot, res: &mut Response) -> Res
|
||||
.await
|
||||
.map_err(|_| StatusError::internal_server_error())?;
|
||||
|
||||
res.redirect_found("/");
|
||||
Redirect::found("/").render(res);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -114,7 +112,7 @@ async fn update(req: &mut Request, depot: &mut Depot, res: &mut Response) -> Res
|
||||
let conn = &state.conn;
|
||||
let id = req.param::<i32>("id").unwrap_or_default();
|
||||
let form = req
|
||||
.extract_form::<post::Model>()
|
||||
.parse_form::<post::Model>()
|
||||
.await
|
||||
.map_err(|_| StatusError::bad_request())?;
|
||||
|
||||
@ -122,7 +120,7 @@ async fn update(req: &mut Request, depot: &mut Depot, res: &mut Response) -> Res
|
||||
.await
|
||||
.map_err(|_| StatusError::internal_server_error())?;
|
||||
|
||||
res.redirect_found("/");
|
||||
Redirect::found("/").render(res);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -138,7 +136,7 @@ async fn delete(req: &mut Request, depot: &mut Depot, res: &mut Response) -> Res
|
||||
.await
|
||||
.map_err(|_| StatusError::internal_server_error())?;
|
||||
|
||||
res.redirect_found("/");
|
||||
Redirect::found("/").render(res);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -170,13 +168,13 @@ pub async fn main() {
|
||||
.push(Router::with_path("<id>").get(edit).post(update))
|
||||
.push(Router::with_path("delete/<id>").post(delete))
|
||||
.push(
|
||||
Router::with_path("static/<**>").get(DirHandler::new(concat!(
|
||||
Router::with_path("static/<**>").get(salvo::prelude::StaticDir::new(concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/static"
|
||||
))),
|
||||
);
|
||||
|
||||
Server::new(TcpListener::bind(&format!("{host}:{port}")))
|
||||
Server::new(TcpListener::bind(TcpListener::new(format!("{host}:{port}"))).await)
|
||||
.serve(router)
|
||||
.await;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
salvo = { version = "0.49" }
|
||||
|
||||
[dependencies.sea-orm]
|
||||
path = "../../../" # remove this line in your own project
|
||||
|
@ -1,7 +1,8 @@
|
||||
use salvo::prelude::Extractible;
|
||||
use sea_orm::entity::prelude::*;
|
||||
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")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
|
@ -11,8 +11,8 @@ members = [".", "api", "service", "entity", "migration"]
|
||||
|
||||
[dependencies]
|
||||
tonic-example-api = { path = "api" }
|
||||
tonic = "0.7"
|
||||
tokio = { version = "1.17", features = ["macros", "rt-multi-thread", "full"] }
|
||||
tonic = "0.9.2"
|
||||
tokio = { version = "1.29", features = ["macros", "rt-multi-thread", "full"] }
|
||||
|
||||
[[bin]]
|
||||
name = "server"
|
||||
|
@ -6,15 +6,15 @@ publish = false
|
||||
|
||||
[dependencies]
|
||||
tonic-example-service = { path = "../service" }
|
||||
tonic = "0.7"
|
||||
tokio = { version = "1.17", features = ["macros", "rt-multi-thread", "full"] }
|
||||
tonic = "0.9.2"
|
||||
tokio = { version = "1.29", features = ["macros", "rt-multi-thread", "full"] }
|
||||
entity = { path = "../entity" }
|
||||
migration = { path = "../migration" }
|
||||
prost = "0.10.0"
|
||||
prost = "0.11.9"
|
||||
serde = "1.0"
|
||||
|
||||
[lib]
|
||||
path = "./src/lib.rs"
|
||||
|
||||
[build-dependencies]
|
||||
tonic-build = "0.7"
|
||||
tonic-build = "0.9.2"
|
||||
|
Loading…
x
Reference in New Issue
Block a user