mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-11-27 11:31:11 +00:00
Update to latest version of actix-web, tracing-bunyan-formatter and tracing-subscriber. Use tokio macros instead of actix-web's macros.
This commit is contained in:
parent
6f79a34d0b
commit
19452d230f
5 changed files with 327 additions and 315 deletions
611
Cargo.lock
generated
611
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
12
Cargo.toml
12
Cargo.toml
|
@ -13,8 +13,8 @@ path = "src/main.rs"
|
|||
name = "zero2prod"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "=4.0.0-beta.9"
|
||||
actix-http = "=3.0.0-beta.10"
|
||||
actix-web = "=4.0.0-beta.15"
|
||||
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
||||
serde = "1.0.115"
|
||||
config = { version = "0.10.1", default-features = false, features = ["yaml"] }
|
||||
sqlx = { version = "0.5.5", default-features = false, features = [ "runtime-actix-rustls", "macros", "postgres", "uuid", "chrono", "migrate", "offline"] }
|
||||
|
@ -24,13 +24,13 @@ reqwest = { version = "0.11", default-features = false, features = ["json", "rus
|
|||
log = "0.4"
|
||||
tracing = "0.1.19"
|
||||
tracing-futures = "0.2.4"
|
||||
tracing-subscriber = { version = "0.2.12", features = ["registry", "env-filter"] }
|
||||
tracing-bunyan-formatter = "0.1.6"
|
||||
tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] }
|
||||
tracing-bunyan-formatter = "0.3.1"
|
||||
tracing-log = "0.1.1"
|
||||
serde-aux = "1.0.1"
|
||||
unicode-segmentation = "1.7.1"
|
||||
tracing-actix-web = "0.5.0-beta.6"
|
||||
validator = "0.12.0"
|
||||
tracing-actix-web = "0.4.0-beta.12"
|
||||
|
||||
[dev-dependencies]
|
||||
claim = "0.4.0"
|
||||
|
@ -39,7 +39,5 @@ quickcheck_macros = "0.9.1"
|
|||
fake = "~2.3.0"
|
||||
wiremock = "0.4.7"
|
||||
serde_json = "1.0.61"
|
||||
actix-rt = "2"
|
||||
tokio = { version = "1", features = ["macros"] }
|
||||
reqwest = { version = "0.11", features = ["json"] }
|
||||
once_cell = "1.7.2"
|
|
@ -5,7 +5,7 @@ use zero2prod::email_client::EmailClient;
|
|||
use zero2prod::startup::run;
|
||||
use zero2prod::telemetry::{get_subscriber, init_subscriber};
|
||||
|
||||
#[actix_web::main]
|
||||
#[tokio::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
let subscriber = get_subscriber("zero2prod".into(), "info".into(), std::io::stdout);
|
||||
init_subscriber(subscriber);
|
||||
|
|
|
@ -11,11 +11,14 @@ use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
|
|||
///
|
||||
/// We are using `impl Subscriber` as return type to avoid having to spell out the actual
|
||||
/// type of the returned subscriber, which is indeed quite complex.
|
||||
pub fn get_subscriber(
|
||||
pub fn get_subscriber<Sink>(
|
||||
name: String,
|
||||
env_filter: String,
|
||||
sink: impl MakeWriter + Send + Sync + 'static,
|
||||
) -> impl Subscriber + Sync + Send {
|
||||
sink: Sink,
|
||||
) -> impl Subscriber + Sync + Send
|
||||
where
|
||||
Sink: for<'a> MakeWriter<'a> + Send + Sync + 'static,
|
||||
{
|
||||
let env_filter =
|
||||
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(env_filter));
|
||||
let formatting_layer = BunyanFormattingLayer::new(name, sink);
|
||||
|
|
|
@ -82,7 +82,7 @@ pub async fn configure_database(config: &DatabaseSettings) -> PgPool {
|
|||
connection_pool
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[tokio::test]
|
||||
async fn health_check_works() {
|
||||
// Arrange
|
||||
let app = spawn_app().await;
|
||||
|
@ -101,7 +101,7 @@ async fn health_check_works() {
|
|||
assert_eq!(Some(0), response.content_length());
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[tokio::test]
|
||||
async fn subscribe_returns_a_200_for_valid_form_data() {
|
||||
// Arrange
|
||||
let app = spawn_app().await;
|
||||
|
@ -129,7 +129,7 @@ async fn subscribe_returns_a_200_for_valid_form_data() {
|
|||
assert_eq!(saved.name, "le guin");
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[tokio::test]
|
||||
async fn subscribe_returns_a_400_when_data_is_missing() {
|
||||
// Arrange
|
||||
let app = spawn_app().await;
|
||||
|
@ -161,7 +161,7 @@ async fn subscribe_returns_a_400_when_data_is_missing() {
|
|||
}
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[tokio::test]
|
||||
async fn subscribe_returns_a_400_when_fields_are_present_but_invalid() {
|
||||
// Arrange
|
||||
let app = spawn_app().await;
|
||||
|
|
Loading…
Reference in a new issue