aquatic_http: move protocol module to new crate aquatic_http_protocol

This commit is contained in:
Joakim Frostegård 2020-07-19 21:59:31 +02:00
parent 4caf174da5
commit 4ac2012a2a
36 changed files with 65 additions and 24 deletions

21
Cargo.lock generated
View file

@ -75,8 +75,7 @@ dependencies = [
"aquatic_cli_helpers", "aquatic_cli_helpers",
"aquatic_common", "aquatic_common",
"aquatic_common_tcp", "aquatic_common_tcp",
"bendy", "aquatic_http_protocol",
"criterion",
"either", "either",
"flume", "flume",
"hashbrown", "hashbrown",
@ -98,6 +97,24 @@ dependencies = [
"smartstring", "smartstring",
] ]
[[package]]
name = "aquatic_http_protocol"
version = "0.1.0"
dependencies = [
"anyhow",
"bendy",
"criterion",
"hashbrown",
"itoa",
"log",
"memchr",
"quickcheck",
"quickcheck_macros",
"rand",
"serde",
"smartstring",
]
[[package]] [[package]]
name = "aquatic_udp" name = "aquatic_udp"
version = "0.1.0" version = "0.1.0"

View file

@ -5,6 +5,7 @@ members = [
"aquatic_common", "aquatic_common",
"aquatic_common_tcp", "aquatic_common_tcp",
"aquatic_http", "aquatic_http",
"aquatic_http_protocol",
"aquatic_udp", "aquatic_udp",
"aquatic_udp_bench", "aquatic_udp_bench",
"aquatic_udp_load_test", "aquatic_udp_load_test",

View file

@ -13,22 +13,12 @@ path = "src/lib/lib.rs"
name = "aquatic_http" name = "aquatic_http"
path = "src/bin/main.rs" path = "src/bin/main.rs"
[[bench]]
name = "bench_request_from_path"
path = "benches/bench_request_from_path.rs"
harness = false
[[bench]]
name = "bench_announce_response_to_bytes"
path = "benches/bench_announce_response_to_bytes.rs"
harness = false
[dependencies] [dependencies]
anyhow = "1" anyhow = "1"
aquatic_cli_helpers = { path = "../aquatic_cli_helpers" } aquatic_cli_helpers = { path = "../aquatic_cli_helpers" }
aquatic_common = { path = "../aquatic_common" } aquatic_common = { path = "../aquatic_common" }
aquatic_common_tcp = { path = "../aquatic_common_tcp" } aquatic_common_tcp = { path = "../aquatic_common_tcp" }
bendy = { version = "0.3", features = ["std", "serde"] } aquatic_http_protocol = { path = "../aquatic_http_protocol" }
either = "1" either = "1"
flume = "0.7" flume = "0.7"
hashbrown = { version = "0.7", features = ["serde"] } hashbrown = { version = "0.7", features = ["serde"] }
@ -48,6 +38,5 @@ simplelog = "0.8"
smartstring = "0.2" smartstring = "0.2"
[dev-dependencies] [dev-dependencies]
criterion = "0.3"
quickcheck = "0.9" quickcheck = "0.9"
quickcheck_macros = "0.9" quickcheck_macros = "0.9"

View file

@ -12,9 +12,9 @@ use smartstring::{SmartString, LazyCompact};
pub use aquatic_common::{ValidUntil, convert_ipv4_mapped_ipv4}; pub use aquatic_common::{ValidUntil, convert_ipv4_mapped_ipv4};
use crate::protocol::common::*; use aquatic_http_protocol::common::*;
use crate::protocol::request::Request; use aquatic_http_protocol::request::Request;
use crate::protocol::response::{Response, ResponsePeer}; use aquatic_http_protocol::response::{Response, ResponsePeer};
pub trait Ip: Copy + Eq + ::std::hash::Hash {} pub trait Ip: Copy + Eq + ::std::hash::Hash {}

View file

@ -8,12 +8,12 @@ use parking_lot::MutexGuard;
use rand::{Rng, SeedableRng, rngs::SmallRng}; use rand::{Rng, SeedableRng, rngs::SmallRng};
use aquatic_common::extract_response_peers; use aquatic_common::extract_response_peers;
use aquatic_http_protocol::request::*;
use aquatic_http_protocol::response::*;
use crate::common::*; use crate::common::*;
use crate::config::Config; use crate::config::Config;
use crate::protocol::request::*;
use crate::protocol::response::*;
pub fn run_request_worker( pub fn run_request_worker(

View file

@ -12,7 +12,6 @@ pub mod common;
pub mod config; pub mod config;
pub mod handler; pub mod handler;
pub mod network; pub mod network;
pub mod protocol;
pub mod tasks; pub mod tasks;
use common::*; use common::*;

View file

@ -9,9 +9,9 @@ use mio::net::TcpStream;
use native_tls::{TlsAcceptor, MidHandshakeTlsStream}; use native_tls::{TlsAcceptor, MidHandshakeTlsStream};
use aquatic_common_tcp::network::stream::Stream; use aquatic_common_tcp::network::stream::Stream;
use aquatic_http_protocol::request::Request;
use crate::common::*; use crate::common::*;
use crate::protocol::request::Request;
#[derive(Debug)] #[derive(Debug)]

View file

@ -12,10 +12,10 @@ use mio::{Events, Poll, Interest, Token};
use mio::net::TcpListener; use mio::net::TcpListener;
use aquatic_common_tcp::network::utils::create_listener; use aquatic_common_tcp::network::utils::create_listener;
use aquatic_http_protocol::response::*;
use crate::common::*; use crate::common::*;
use crate::config::Config; use crate::config::Config;
use crate::protocol::response::*;
use connection::*; use connection::*;

View file

@ -0,0 +1,35 @@
[package]
name = "aquatic_http_protocol"
version = "0.1.0"
authors = ["Joakim Frostegård <joakim.frostegard@gmail.com>"]
edition = "2018"
license = "Apache-2.0"
[lib]
name = "aquatic_http_protocol"
[[bench]]
name = "bench_request_from_path"
path = "benches/bench_request_from_path.rs"
harness = false
[[bench]]
name = "bench_announce_response_to_bytes"
path = "benches/bench_announce_response_to_bytes.rs"
harness = false
[dependencies]
anyhow = "1"
bendy = { version = "0.3", features = ["std", "serde"] }
hashbrown = { version = "0.7", features = ["serde"] }
itoa = "0.4"
log = "0.4"
memchr = "2"
rand = { version = "0.7", features = ["small_rng"] }
serde = { version = "1", features = ["derive"] }
smartstring = "0.2"
[dev-dependencies]
criterion = "0.3"
quickcheck = "0.9"
quickcheck_macros = "0.9"

View file

@ -3,7 +3,7 @@ use std::time::Duration;
use criterion::{black_box, criterion_group, criterion_main, Criterion}; use criterion::{black_box, criterion_group, criterion_main, Criterion};
use aquatic_http::protocol::response::*; use aquatic_http_protocol::response::*;
pub fn bench(c: &mut Criterion) { pub fn bench(c: &mut Criterion) {

View file

@ -1,7 +1,7 @@
use std::time::Duration; use std::time::Duration;
use criterion::{black_box, criterion_group, criterion_main, Criterion}; use criterion::{black_box, criterion_group, criterion_main, Criterion};
use aquatic_http::protocol::request::Request; use aquatic_http_protocol::request::Request;
static INPUT: &str = "/announce?info_hash=%04%0bkV%3f%5cr%14%a6%b7%98%adC%c3%c9.%40%24%00%b9&peer_id=-TR2940-5ert69muw5t8&port=11000&uploaded=0&downloaded=0&left=0&numwant=0&key=3ab4b977&compact=1&supportcrypto=1&event=stopped"; static INPUT: &str = "/announce?info_hash=%04%0bkV%3f%5cr%14%a6%b7%98%adC%c3%c9.%40%24%00%b9&peer_id=-TR2940-5ert69muw5t8&port=11000&uploaded=0&downloaded=0&left=0&numwant=0&key=3ab4b977&compact=1&supportcrypto=1&event=stopped";