Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update example's dependency versions #1759

Merged
merged 9 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,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: stable
Expand Down
6 changes: 3 additions & 3 deletions examples/actix_example/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
16 changes: 8 additions & 8 deletions examples/axum_example/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion examples/axum_example/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"),
Expand Down
4 changes: 2 additions & 2 deletions examples/basic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ 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" }
async-stream = { version = "0.3" }
futures-util = { version = "0.3" }
futures-util = { version = "0.3" }
11 changes: 6 additions & 5 deletions examples/graphql_example/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
migration = { path = "../migration" }
8 changes: 5 additions & 3 deletions examples/graphql_example/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand All @@ -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");

Expand Down
2 changes: 1 addition & 1 deletion examples/graphql_example/entity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions examples/jsonrpsee_example/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
22 changes: 12 additions & 10 deletions examples/jsonrpsee_example/api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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::<()>))
}
}

Expand All @@ -112,21 +113,22 @@ 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 };
let server_addr = server.local_addr().unwrap();
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();
Expand Down
6 changes: 3 additions & 3 deletions examples/poem_example/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
2 changes: 1 addition & 1 deletion examples/rocket_example/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions examples/salvo_example/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
migration = { path = "../migration" }
18 changes: 8 additions & 10 deletions examples/salvo_example/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -29,15 +27,15 @@ 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())?;

Mutation::create_post(conn, form)
.await
.map_err(|_| StatusError::internal_server_error())?;

res.redirect_found("/");
Redirect::found("/").render(res);
Ok(())
}

Expand Down Expand Up @@ -114,15 +112,15 @@ 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())?;

Mutation::update_post_by_id(conn, id, form)
.await
.map_err(|_| StatusError::internal_server_error())?;

res.redirect_found("/");
Redirect::found("/").render(res);
Ok(())
}

Expand All @@ -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(())
}

Expand Down Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions examples/salvo_example/entity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion examples/salvo_example/entity/src/post.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions examples/tonic_example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions examples/tonic_example/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"