Skip to content

Commit 3daf3f1

Browse files
committed
refactor: [#1294] extract axum-server package
1 parent df762d9 commit 3daf3f1

File tree

11 files changed

+720
-4
lines changed

11 files changed

+720
-4
lines changed

.github/workflows/deployment.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
cargo publish -p bittorrent-tracker-core
6262
cargo publish -p bittorrent-udp-tracker-core
6363
cargo publish -p bittorrent-udp-tracker-protocol
64+
cargo publish -p torrust-axum-server
6465
cargo publish -p torrust-tracker
6566
cargo publish -p torrust-tracker-api-client
6667
cargo publish -p torrust-tracker-api-core

Cargo.lock

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ axum = { version = "0", features = ["macros"] }
3939
axum-client-ip = "0"
4040
axum-extra = { version = "0", features = ["query"] }
4141
axum-server = { version = "0", features = ["tls-rustls-no-provider"] }
42-
bittorrent-http-tracker-protocol = { version = "3.0.0-develop", path = "packages/http-protocol" }
4342
bittorrent-http-tracker-core = { version = "3.0.0-develop", path = "packages/http-tracker-core" }
43+
bittorrent-http-tracker-protocol = { version = "3.0.0-develop", path = "packages/http-protocol" }
4444
bittorrent-primitives = "0.1.0"
4545
bittorrent-tracker-client = { version = "3.0.0-develop", path = "packages/tracker-client" }
4646
bittorrent-tracker-core = { version = "3.0.0-develop", path = "packages/tracker-core" }
@@ -76,6 +76,7 @@ serde_repr = "0"
7676
serde_with = { version = "3", features = ["json"] }
7777
thiserror = "2"
7878
tokio = { version = "1", features = ["macros", "net", "rt-multi-thread", "signal", "sync"] }
79+
torrust-axum-server = { version = "3.0.0-develop", path = "packages/axum-server" }
7980
torrust-tracker-api-core = { version = "3.0.0-develop", path = "packages/tracker-api-core" }
8081
torrust-tracker-clock = { version = "3.0.0-develop", path = "packages/clock" }
8182
torrust-tracker-configuration = { version = "3.0.0-develop", path = "packages/configuration" }

packages/axum-server/Cargo.toml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[package]
2+
authors.workspace = true
3+
description = "A wrapper for the Axum server for Torrust HTTP servers to add timeouts."
4+
documentation.workspace = true
5+
edition.workspace = true
6+
homepage.workspace = true
7+
keywords = ["axum", "server", "torrust", "torrust", "wrapper"]
8+
license.workspace = true
9+
name = "torrust-axum-server"
10+
publish.workspace = true
11+
readme = "README.md"
12+
repository.workspace = true
13+
rust-version.workspace = true
14+
version.workspace = true
15+
16+
[dependencies]
17+
axum-server = { version = "0", features = ["tls-rustls-no-provider"] }
18+
futures-util = "0"
19+
http-body = "1"
20+
hyper = "1"
21+
hyper-util = { version = "0", features = ["http1", "http2", "tokio"] }
22+
pin-project-lite = "0"
23+
tokio = { version = "1", features = ["macros", "net", "rt-multi-thread", "signal", "sync"] }
24+
tower = { version = "0", features = ["timeout"] }
25+
26+
[dev-dependencies]

packages/axum-server/LICENSE

+661
Large diffs are not rendered by default.

packages/axum-server/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Torrust Axum Server
2+
3+
A wrapper for the Axum server for Torrust HTTP servers to add timeouts.
4+
5+
## Documentation
6+
7+
[Crate documentation](https://docs.rs/torrust-axum-server).
8+
9+
## License
10+
11+
The project is licensed under the terms of the [GNU AFFERO GENERAL PUBLIC LICENSE](./LICENSE).

packages/axum-server/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod custom_axum_server;

src/servers/apis/server.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ use derive_more::Constructor;
3333
use futures::future::BoxFuture;
3434
use thiserror::Error;
3535
use tokio::sync::oneshot::{Receiver, Sender};
36+
use torrust_axum_server::custom_axum_server::{self, TimeoutAcceptor};
3637
use torrust_tracker_configuration::AccessTokens;
3738
use tracing::{instrument, Level};
3839

3940
use super::routes::router;
4041
use crate::bootstrap::jobs::Started;
4142
use crate::container::HttpApiContainer;
4243
use crate::servers::apis::API_LOG_TARGET;
43-
use crate::servers::custom_axum_server::{self, TimeoutAcceptor};
4444
use crate::servers::logging::STARTED_ON;
4545
use crate::servers::registar::{ServiceHealthCheckJob, ServiceRegistration, ServiceRegistrationForm};
4646
use crate::servers::signals::{graceful_shutdown, Halted};

src/servers/http/server.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ use axum_server::Handle;
77
use derive_more::Constructor;
88
use futures::future::BoxFuture;
99
use tokio::sync::oneshot::{Receiver, Sender};
10+
use torrust_axum_server::custom_axum_server::{self, TimeoutAcceptor};
1011
use tracing::instrument;
1112

1213
use super::v1::routes::router;
1314
use crate::bootstrap::jobs::Started;
1415
use crate::container::HttpTrackerContainer;
15-
use crate::servers::custom_axum_server::{self, TimeoutAcceptor};
1616
use crate::servers::http::HTTP_TRACKER_LOG_TARGET;
1717
use crate::servers::logging::STARTED_ON;
1818
use crate::servers::registar::{ServiceHealthCheckJob, ServiceRegistration, ServiceRegistrationForm};

src/servers/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Servers. Services that can be started and stopped.
22
pub mod apis;
3-
pub mod custom_axum_server;
43
pub mod health_check_api;
54
pub mod http;
65
pub mod logging;

0 commit comments

Comments
 (0)