rename lol

This commit is contained in:
nora 2022-03-19 14:27:30 +01:00
parent c68cd04af7
commit 543e39f129
70 changed files with 283 additions and 266 deletions

4
.gitattributes vendored
View file

@ -1,2 +1,2 @@
amqp_core/src/methods/generated.rs linguist-generated
amqp_transport/src/methods/generated.rs linguist-generated
haesli_core/src/methods/generated.rs linguist-generated
haesli_transport/src/methods/generated.rs linguist-generated

235
Cargo.lock generated
View file

@ -21,82 +21,17 @@ dependencies = [
name = "amqp"
version = "0.1.0"
dependencies = [
"amqp_core",
"amqp_dashboard",
"amqp_transport",
"anyhow",
"clap 3.1.5",
"clap 3.1.6",
"haesli_core",
"haesli_dashboard",
"haesli_transport",
"tokio",
"tracing",
"tracing-subscriber",
"tracing-tree",
]
[[package]]
name = "amqp_core"
version = "0.1.0"
dependencies = [
"amqp_datastructure",
"bytes",
"parking_lot",
"rand",
"smallvec",
"thiserror",
"tokio",
"uuid",
]
[[package]]
name = "amqp_dashboard"
version = "0.1.0"
dependencies = [
"amqp_core",
"anyhow",
"axum",
"mime_guess",
"serde",
"tokio",
"tower",
"tower-http",
"tracing",
"walkdir",
"zip",
]
[[package]]
name = "amqp_datastructure"
version = "0.1.0"
[[package]]
name = "amqp_messaging"
version = "0.1.0"
dependencies = [
"amqp_core",
"amqp_datastructure",
"parking_lot",
"tokio",
"tracing",
]
[[package]]
name = "amqp_transport"
version = "0.1.0"
dependencies = [
"amqp_core",
"amqp_messaging",
"anyhow",
"bytes",
"criterion",
"nom",
"once_cell",
"rand",
"regex",
"smallvec",
"thiserror",
"tokio",
"tracing",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
@ -108,9 +43,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.55"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "159bb86af3a200e19a068f4224eae4c8bb2d0fa054c7e5d1cacd5cef95e684cd"
checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27"
[[package]]
name = "async-trait"
@ -172,9 +107,9 @@ dependencies = [
[[package]]
name = "axum-core"
version = "0.1.1"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ca6c0b218388a7ed6a8d25e94f7dea5498daaa4fd8c711fb3ff166041b06fda"
checksum = "6dbcda393bef9c87572779cb8ef916f12d77750b27535dd6819fa86591627a51"
dependencies = [
"async-trait",
"bytes",
@ -275,9 +210,9 @@ dependencies = [
[[package]]
name = "clap"
version = "3.1.5"
version = "3.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ced1892c55c910c1219e98d6fc8d71f6bddba7905866ce740066d8bfea859312"
checksum = "d8c93436c21e4698bacadf42917db28b23017027a4deccb35dbe47a7e7840123"
dependencies = [
"atty",
"bitflags",
@ -350,9 +285,9 @@ dependencies = [
[[package]]
name = "crossbeam-channel"
version = "0.5.2"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa"
checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53"
dependencies = [
"cfg-if",
"crossbeam-utils",
@ -371,10 +306,11 @@ dependencies = [
[[package]]
name = "crossbeam-epoch"
version = "0.9.7"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9"
checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c"
dependencies = [
"autocfg",
"cfg-if",
"crossbeam-utils",
"lazy_static",
@ -384,9 +320,9 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.8.7"
version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6"
checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38"
dependencies = [
"cfg-if",
"lazy_static",
@ -489,13 +425,78 @@ dependencies = [
[[package]]
name = "getrandom"
version = "0.2.4"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c"
checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77"
dependencies = [
"cfg-if",
"libc",
"wasi",
"wasi 0.10.2+wasi-snapshot-preview1",
]
[[package]]
name = "haesli_core"
version = "0.1.0"
dependencies = [
"bytes",
"haesli_datastructure",
"parking_lot",
"rand",
"smallvec",
"thiserror",
"tokio",
"uuid",
]
[[package]]
name = "haesli_dashboard"
version = "0.1.0"
dependencies = [
"anyhow",
"axum",
"haesli_core",
"mime_guess",
"serde",
"tokio",
"tower",
"tower-http",
"tracing",
"walkdir",
"zip",
]
[[package]]
name = "haesli_datastructure"
version = "0.1.0"
[[package]]
name = "haesli_messaging"
version = "0.1.0"
dependencies = [
"haesli_core",
"haesli_datastructure",
"parking_lot",
"tokio",
"tracing",
]
[[package]]
name = "haesli_transport"
version = "0.1.0"
dependencies = [
"anyhow",
"bytes",
"criterion",
"haesli_core",
"haesli_messaging",
"nom",
"once_cell",
"rand",
"regex",
"smallvec",
"thiserror",
"tokio",
"tracing",
]
[[package]]
@ -642,9 +643,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.119"
version = "0.2.121"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
[[package]]
name = "lock_api"
@ -734,14 +735,15 @@ dependencies = [
[[package]]
name = "mio"
version = "0.8.0"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2"
checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9"
dependencies = [
"libc",
"log",
"miow",
"ntapi",
"wasi 0.11.0+wasi-snapshot-preview1",
"winapi",
]
@ -756,13 +758,12 @@ dependencies = [
[[package]]
name = "nom"
version = "7.1.0"
version = "7.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109"
checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
dependencies = [
"memchr",
"minimal-lexical",
"version_check",
]
[[package]]
@ -795,9 +796,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.9.0"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
[[package]]
name = "oorandom"
@ -950,9 +951,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.15"
version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
checksum = "b4af2ec4714533fcdf07e886f17025ace8b997b9ce51204ee69b6da831c3da57"
dependencies = [
"proc-macro2",
]
@ -1014,18 +1015,18 @@ dependencies = [
[[package]]
name = "redox_syscall"
version = "0.2.10"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c"
dependencies = [
"bitflags",
]
[[package]]
name = "regex"
version = "1.5.4"
version = "1.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
dependencies = [
"aho-corasick",
"memchr",
@ -1079,9 +1080,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "semver"
version = "1.0.5"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0486718e92ec9a68fbed73bb5ef687d71103b142595b406835649bebd33f72c7"
checksum = "a4a3381e03edd24287172047536f20cabde766e2cd3e65e6b00fb3af51c4f38d"
[[package]]
name = "serde"
@ -1202,9 +1203,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "1.0.86"
version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b"
checksum = "ea297be220d52398dcc07ce15a209fce436d361735ac1db700cab3b6cdfb9f54"
dependencies = [
"proc-macro2",
"quote",
@ -1219,9 +1220,9 @@ checksum = "20518fe4a4c9acf048008599e464deb21beeae3d3578418951a189c235a7a9a8"
[[package]]
name = "termcolor"
version = "1.1.2"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
dependencies = [
"winapi-util",
]
@ -1354,9 +1355,9 @@ dependencies = [
[[package]]
name = "tower-http"
version = "0.2.3"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bb284cac1883d54083a0edbdc9cabf931dfed87455f8c7266c01ece6394a43a"
checksum = "aba3f3efabf7fb41fae8534fc20a817013dd1c12cb45441efb6c82e6556b4cd8"
dependencies = [
"bitflags",
"bytes",
@ -1385,9 +1386,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6"
[[package]]
name = "tracing"
version = "0.1.31"
version = "0.1.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6c650a8ef0cd2dd93736f033d21cbd1224c5a967aa0c258d00fcf7dafef9b9f"
checksum = "4a1bdf54a7c28a2bbf701e1d2233f6c77f473486b94bee4f9678da5a148dca7f"
dependencies = [
"cfg-if",
"log",
@ -1398,9 +1399,9 @@ dependencies = [
[[package]]
name = "tracing-attributes"
version = "0.1.19"
version = "0.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8276d9a4a3a558d7b7ad5303ad50b53d58264641b82914b7ada36bd762e7a716"
checksum = "2e65ce065b4b5c53e73bb28912318cb8c9e9ad3921f1d669eb0e68b4c8143a2b"
dependencies = [
"proc-macro2",
"quote",
@ -1409,9 +1410,9 @@ dependencies = [
[[package]]
name = "tracing-core"
version = "0.1.22"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03cfcb51380632a72d3111cb8d3447a8d908e577d31beeac006f836383d29a23"
checksum = "aa31669fa42c09c34d94d8165dd2012e8ff3c66aca50f3bb226b68f216f2706c"
dependencies = [
"lazy_static",
"valuable",
@ -1531,6 +1532,12 @@ version = "0.10.2+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.79"
@ -1680,7 +1687,7 @@ name = "xtask"
version = "0.1.0"
dependencies = [
"anyhow",
"clap 3.1.5",
"clap 3.1.6",
"heck",
"itertools",
"strong-xml",

View file

@ -1,11 +1,11 @@
[workspace]
members = [
".",
"amqp_core",
"amqp_dashboard",
"amqp_datastructure",
"amqp_messaging",
"amqp_transport",
"haesli_core",
"haesli_dashboard",
"haesli_datastructure",
"haesli_messaging",
"haesli_transport",
"xtask",
]
@ -18,9 +18,9 @@ edition = "2021"
[dependencies]
anyhow = "1.0.53"
amqp_core = { path = "./amqp_core" }
amqp_dashboard = { path = "./amqp_dashboard" }
amqp_transport = { path = "./amqp_transport" }
haesli_core = { path = "./haesli_core" }
haesli_dashboard = { path = "./haesli_dashboard" }
haesli_transport = { path = "./haesli_transport" }
clap = { version = "3.1.5", features = ["derive"] }
tokio = { version = "1.16.1", features = ["full"] }
tracing = "0.1.30"

View file

@ -1,7 +1,12 @@
# amqp
# Haesli - AMQP implementation in Rust
[amqp0-9-1 spec pdf](https://www.rabbitmq.com/resources/specs/amqp0-9-1.pdf)
**This is still work in progress!**
[amqp 0-9-1 spec generated_pdf](https://www.rabbitmq.com/resources/specs/amqp-xml-doc0-9-1.pdf)
[amqp0-9-1 spec xml](https://www.rabbitmq.com/resources/specs/amqp0-9-1.xml)
## Relevant links
[AMQP-0-9-1 specification](https://www.rabbitmq.com/resources/specs/amqp0-9-1.pdf)
[AMQP 0-9-1 specification generated method PDF](https://www.rabbitmq.com/resources/specs/amqp-xml-doc0-9-1.pdf)
[AMQP 0-9-1 specification method XML](https://www.rabbitmq.com/resources/specs/amqp0-9-1.xml)

View file

@ -1,61 +0,0 @@
mod consume;
mod publish;
mod queue;
use amqp_core::{amqp_todo, connection::Channel, message::Message, methods::Method};
use tracing::info;
use crate::Result;
pub fn handle_basic_publish(channel_handle: Channel, message: Message) -> Result<()> {
publish::publish(channel_handle, message)
}
pub async fn handle_method(channel_handle: Channel, method: Method) -> Result<Method> {
info!(?method, "Handling method");
let response = match method {
Method::ExchangeDeclare(_) => amqp_todo!(),
Method::ExchangeDeclareOk(_) => amqp_todo!(),
Method::ExchangeDelete(_) => amqp_todo!(),
Method::ExchangeDeleteOk(_) => amqp_todo!(),
Method::QueueDeclare(queue_declare) => queue::declare(channel_handle, queue_declare)?,
Method::QueueDeclareOk { .. } => amqp_todo!(),
Method::QueueBind(queue_bind) => queue::bind(channel_handle, queue_bind).await?,
Method::QueueBindOk(_) => amqp_todo!(),
Method::QueueUnbind { .. } => amqp_todo!(),
Method::QueueUnbindOk(_) => amqp_todo!(),
Method::QueuePurge { .. } => amqp_todo!(),
Method::QueuePurgeOk { .. } => amqp_todo!(),
Method::QueueDelete { .. } => amqp_todo!(),
Method::QueueDeleteOk { .. } => amqp_todo!(),
Method::BasicQos { .. } => amqp_todo!(),
Method::BasicQosOk(_) => amqp_todo!(),
Method::BasicConsume(consume) => consume::consume(channel_handle, consume)?,
Method::BasicConsumeOk { .. } => amqp_todo!(),
Method::BasicCancel { .. } => amqp_todo!(),
Method::BasicCancelOk { .. } => amqp_todo!(),
Method::BasicReturn { .. } => amqp_todo!(),
Method::BasicDeliver { .. } => amqp_todo!(),
Method::BasicGet { .. } => amqp_todo!(),
Method::BasicGetOk { .. } => amqp_todo!(),
Method::BasicGetEmpty { .. } => amqp_todo!(),
Method::BasicAck { .. } => amqp_todo!(),
Method::BasicReject { .. } => amqp_todo!(),
Method::BasicRecoverAsync { .. } => amqp_todo!(),
Method::BasicRecover { .. } => amqp_todo!(),
Method::BasicRecoverOk(_) => amqp_todo!(),
Method::TxSelect(_)
| Method::TxSelectOk(_)
| Method::TxCommit(_)
| Method::TxCommitOk(_)
| Method::TxRollback(_)
| Method::TxRollbackOk(_) => amqp_todo!(),
Method::BasicPublish { .. } => {
unreachable!("Basic.Publish is handled somewhere else because it has a body")
}
_ => unreachable!("Method handled by transport layer"),
};
Ok(response)
}

View file

@ -1,12 +1,12 @@
[package]
name = "amqp_core"
name = "haesli_core"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
amqp_datastructure = { path = "../amqp_datastructure" }
haesli_datastructure = { path = "../haesli_datastructure" }
bytes = "1.1.0"
parking_lot = "0.12.0"
rand = "0.8.5"

View file

@ -62,10 +62,13 @@ macro_rules! newtype {
}
#[macro_export]
macro_rules! amqp_todo {
macro_rules! haesli_todo {
() => {
return Err(
::amqp_core::error::ConException::NotImplemented(concat!(file!(), ":", line!())).into(),
)
return Err(::haesli_core::error::ConException::NotImplemented(concat!(
file!(),
":",
line!()
))
.into())
};
}

View file

@ -49,7 +49,7 @@ impl Display for QueueName {
pub struct QueueInner {
pub id: QueueId,
pub name: QueueName,
pub messages: amqp_datastructure::MessageQueue<Message>,
pub messages: haesli_datastructure::MessageQueue<Message>,
pub durable: bool,
pub exclusive: Option<ChannelId>,
/// Whether the queue will automatically be deleted when no consumers uses it anymore.

View file

@ -1,12 +1,12 @@
[package]
name = "amqp_dashboard"
name = "haesli_dashboard"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
amqp_core = { path = "../amqp_core" }
haesli_core = { path = "../haesli_core" }
anyhow = "1.0.55"
axum = "0.4.8"
mime_guess = "2.0.4"

View file

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

Before After
Before After

View file

@ -10,7 +10,7 @@ const App = () => {
return (
<div className="app">
<header className="header">
<h1>AMQP Dashboard</h1>
<h1>Haesli Dashboard</h1>
</header>
<DataPage prefix={URL_PREFIX} />
</div>

View file

@ -2,13 +2,13 @@
mod archive;
use amqp_core::GlobalData;
use axum::{
http::{Method, StatusCode},
response::IntoResponse,
routing::{get, get_service},
Json, Router,
};
use haesli_core::GlobalData;
use serde::Serialize;
use tower_http::cors::{Any, CorsLayer};
use tracing::{error, info};

View file

@ -1,5 +1,5 @@
[package]
name = "amqp_datastructure"
name = "haesli_datastructure"
version = "0.1.0"
edition = "2021"

View file

@ -1,13 +1,13 @@
[package]
name = "amqp_messaging"
name = "haesli_messaging"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
amqp_core = { path = "../amqp_core" }
amqp_datastructure = { path = "../amqp_datastructure" }
haesli_core = { path = "../haesli_core" }
haesli_datastructure = { path = "../haesli_datastructure" }
parking_lot = "0.12.0"
tracing = "0.1.31"
tokio = { version = "1.17.0", features = ["full"] }

View file

@ -1,7 +1,7 @@
#![warn(rust_2018_idioms)]
#![deny(clippy::future_not_send)]
use amqp_core::error::ProtocolError;
use haesli_core::error::ProtocolError;
pub mod methods;
mod queue_worker;

View file

@ -1,10 +1,10 @@
use std::sync::Arc;
use amqp_core::{
amqp_todo,
use haesli_core::{
connection::Channel,
consumer::{Consumer, ConsumerId},
error::ChannelException,
haesli_todo,
methods::{BasicConsume, BasicConsumeOk, Method},
};
use tracing::info;
@ -23,13 +23,13 @@ pub fn consume(channel: Channel, basic_consume: BasicConsume) -> Result<Method>
} = basic_consume;
if no_wait || no_local || exclusive || no_ack {
amqp_todo!();
haesli_todo!();
}
let global_data = channel.global_data.clone();
let consumer_tag = if consumer_tag.is_empty() {
amqp_core::random_uuid().to_string()
haesli_core::random_uuid().to_string()
} else {
consumer_tag
};

View file

@ -0,0 +1,61 @@
mod consume;
mod publish;
mod queue;
use haesli_core::{connection::Channel, haesli_todo, message::Message, methods::Method};
use tracing::info;
use crate::Result;
pub fn handle_basic_publish(channel_handle: Channel, message: Message) -> Result<()> {
publish::publish(channel_handle, message)
}
pub async fn handle_method(channel_handle: Channel, method: Method) -> Result<Method> {
info!(?method, "Handling method");
let response = match method {
Method::ExchangeDeclare(_) => haesli_todo!(),
Method::ExchangeDeclareOk(_) => haesli_todo!(),
Method::ExchangeDelete(_) => haesli_todo!(),
Method::ExchangeDeleteOk(_) => haesli_todo!(),
Method::QueueDeclare(queue_declare) => queue::declare(channel_handle, queue_declare)?,
Method::QueueDeclareOk { .. } => haesli_todo!(),
Method::QueueBind(queue_bind) => queue::bind(channel_handle, queue_bind).await?,
Method::QueueBindOk(_) => haesli_todo!(),
Method::QueueUnbind { .. } => haesli_todo!(),
Method::QueueUnbindOk(_) => haesli_todo!(),
Method::QueuePurge { .. } => haesli_todo!(),
Method::QueuePurgeOk { .. } => haesli_todo!(),
Method::QueueDelete { .. } => haesli_todo!(),
Method::QueueDeleteOk { .. } => haesli_todo!(),
Method::BasicQos { .. } => haesli_todo!(),
Method::BasicQosOk(_) => haesli_todo!(),
Method::BasicConsume(consume) => consume::consume(channel_handle, consume)?,
Method::BasicConsumeOk { .. } => haesli_todo!(),
Method::BasicCancel { .. } => haesli_todo!(),
Method::BasicCancelOk { .. } => haesli_todo!(),
Method::BasicReturn { .. } => haesli_todo!(),
Method::BasicDeliver { .. } => haesli_todo!(),
Method::BasicGet { .. } => haesli_todo!(),
Method::BasicGetOk { .. } => haesli_todo!(),
Method::BasicGetEmpty { .. } => haesli_todo!(),
Method::BasicAck { .. } => haesli_todo!(),
Method::BasicReject { .. } => haesli_todo!(),
Method::BasicRecoverAsync { .. } => haesli_todo!(),
Method::BasicRecover { .. } => haesli_todo!(),
Method::BasicRecoverOk(_) => haesli_todo!(),
Method::TxSelect(_)
| Method::TxSelectOk(_)
| Method::TxCommit(_)
| Method::TxCommitOk(_)
| Method::TxRollback(_)
| Method::TxRollbackOk(_) => haesli_todo!(),
Method::BasicPublish { .. } => {
unreachable!("Basic.Publish is handled somewhere else because it has a body")
}
_ => unreachable!("Method handled by transport layer"),
};
Ok(response)
}

View file

@ -1,7 +1,7 @@
use amqp_core::{
amqp_todo,
use haesli_core::{
connection::Channel,
error::{ChannelException, ConException},
haesli_todo,
message::Message,
queue::QueueEvent,
};
@ -17,7 +17,7 @@ pub fn publish(channel_handle: Channel, message: Message) -> Result<()> {
let routing = &message.routing;
if !routing.exchange.is_empty() {
amqp_todo!();
haesli_todo!();
}
let global_data = global_data.lock();

View file

@ -1,8 +1,8 @@
use std::sync::{atomic::AtomicUsize, Arc};
use amqp_core::{
amqp_todo,
use haesli_core::{
connection::Channel,
haesli_todo,
methods::{Method, QueueBind, QueueDeclare, QueueDeclareOk},
queue::{QueueDeletion, QueueId, QueueInner, QueueName},
GlobalData,
@ -27,13 +27,13 @@ pub fn declare(channel: Channel, queue_declare: QueueDeclare) -> Result<Method>
let queue_name = QueueName::new(queue_name.into());
if !arguments.is_empty() {
amqp_todo!();
haesli_todo!();
}
// todo: durable is technically spec-compliant, the spec doesn't really require it, but it's a todo
// not checked here because it's the default for amqplib which is annoying
if passive || no_wait {
amqp_todo!();
haesli_todo!();
}
let global_data = channel.global_data.clone();
@ -44,7 +44,7 @@ pub fn declare(channel: Channel, queue_declare: QueueDeclare) -> Result<Method>
let queue = Arc::new(QueueInner {
id,
name: queue_name.clone(),
messages: amqp_datastructure::MessageQueue::new(),
messages: haesli_datastructure::MessageQueue::new(),
durable,
exclusive: exclusive.then(|| channel.id),
deletion: if auto_delete {
@ -79,7 +79,7 @@ pub fn declare(channel: Channel, queue_declare: QueueDeclare) -> Result<Method>
}
pub async fn bind(_channel_handle: Channel, _queue_bind: QueueBind) -> Result<Method> {
amqp_todo!();
haesli_todo!();
}
fn bind_queue(global_data: GlobalData, _exchange: (), routing_key: Arc<str>) -> Result<()> {

View file

@ -1,6 +1,6 @@
use std::borrow::Borrow;
use amqp_core::{
use haesli_core::{
connection::ConnectionEvent,
consumer::Consumer,
message::Message,

View file

@ -1,13 +1,13 @@
[package]
name = "amqp_transport"
name = "haesli_transport"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
amqp_core = { path = "../amqp_core" }
amqp_messaging = { path = "../amqp_messaging" }
haesli_core = { path = "../haesli_core" }
haesli_messaging = { path = "../haesli_messaging" }
anyhow = "1.0.53"
bytes = "1.1.0"
nom = "7.1.0"

View file

@ -1,8 +1,8 @@
use amqp_core::methods::Method;
use amqp_transport::methods::{
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use haesli_core::methods::Method;
use haesli_transport::methods::{
RandomMethod, {self},
};
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use rand::SeedableRng;
fn random_method_from_seed(seed: u128) -> Method {

View file

@ -2,7 +2,9 @@ use std::{
cmp::Ordering, collections::HashMap, net::SocketAddr, pin::Pin, sync::Arc, time::Duration,
};
use amqp_core::{
use anyhow::{anyhow, Context};
use bytes::Bytes;
use haesli_core::{
connection::{
Channel, ChannelInner, ChannelNum, ConEventReceiver, ConEventSender, Connection,
ConnectionEvent, ConnectionId, ContentHeader,
@ -15,8 +17,6 @@ use amqp_core::{
},
GlobalData,
};
use anyhow::{anyhow, Context};
use bytes::Bytes;
use smallvec::SmallVec;
use tokio::{
io::{AsyncReadExt, AsyncWriteExt},
@ -399,11 +399,11 @@ impl TransportConnection {
.global_chan
.clone();
// call into amqp_messaging to handle the method
// call into haesli_messaging to handle the method
// it returns the response method that we are supposed to send
// maybe this might become an `Option` in the future
let return_method =
amqp_messaging::methods::handle_method(channel_handle, method).await?;
haesli_messaging::methods::handle_method(channel_handle, method).await?;
self.send_method(frame.channel, &return_method).await?;
}
}
@ -499,7 +499,7 @@ impl TransportConnection {
let channel = self.channels.get(&channel).ok_or(ConException::Todo)?;
amqp_messaging::methods::handle_basic_publish(channel.global_chan.clone(), message)?;
haesli_messaging::methods::handle_basic_publish(channel.global_chan.clone(), message)?;
Ok(())
} else {
Err(ConException::Todo.into())

View file

@ -1,6 +1,6 @@
use std::io::Error;
pub use amqp_core::error::{ConException, ProtocolError};
pub use haesli_core::error::{ConException, ProtocolError};
type StdResult<T, E> = std::result::Result<T, E>;
@ -20,7 +20,7 @@ impl From<std::io::Error> for TransError {
}
}
impl From<amqp_core::error::ConException> for TransError {
impl From<haesli_core::error::ConException> for TransError {
fn from(err: ConException) -> Self {
Self::Protocol(ProtocolError::ConException(err))
}

View file

@ -3,9 +3,9 @@ use std::{
num::NonZeroUsize,
};
use amqp_core::connection::{ChannelNum, ContentHeader};
use anyhow::Context;
use bytes::Bytes;
use haesli_core::connection::{ChannelNum, ContentHeader};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tracing::trace;
@ -39,7 +39,7 @@ pub enum FrameType {
}
mod content_header_parse {
use amqp_core::{
use haesli_core::{
connection::ContentHeader,
methods::{
self,
@ -140,7 +140,7 @@ pub fn parse_content_header(input: &[u8]) -> Result<ContentHeader> {
mod content_header_write {
use std::io::Write;
use amqp_core::{
use haesli_core::{
connection::ContentHeader,
methods::{
FieldValue::{FieldTable, ShortShortUInt, ShortString, Timestamp},

View file

@ -12,8 +12,8 @@ mod tests;
use std::{future::Future, net::SocketAddr};
use amqp_core::{connection::ConnectionEvent, queue::QueueEvent, GlobalData};
use anyhow::Context;
use haesli_core::{connection::ConnectionEvent, queue::QueueEvent, GlobalData};
use tokio::{net, net::TcpStream, select};
use tracing::{info, info_span, Instrument};
@ -53,7 +53,7 @@ fn handle_con(global_data: GlobalData, connection: (TcpStream, SocketAddr)) {
let (method_send, method_recv) = tokio::sync::mpsc::channel(10);
let connection_handle = amqp_core::connection::ConnectionInner::new(
let connection_handle = haesli_core::connection::ConnectionInner::new(
id,
peer_addr,
global_data.clone(),

View file

@ -2,7 +2,7 @@
// This file has been generated by `xtask/src/codegen`. Do not edit it manually.
pub mod parse {
use amqp_core::methods::*;
use haesli_core::methods::*;
use nom::{branch::alt, bytes::complete::tag};
use once_cell::sync::Lazy;
use regex::Regex;
@ -889,7 +889,7 @@ pub mod parse {
pub mod write {
use std::io::Write;
use amqp_core::methods::*;
use haesli_core::methods::*;
use crate::{error::TransError, methods::write_helper::*};
@ -1306,7 +1306,7 @@ pub mod write {
}
mod random {
use amqp_core::methods::*;
use haesli_core::methods::*;
use rand::Rng;
use crate::methods::RandomMethod;

View file

@ -1,4 +1,4 @@
use amqp_core::{
use haesli_core::{
error::ConException,
methods::{FieldValue, Method, Table},
};

View file

@ -1,4 +1,4 @@
use amqp_core::{
use haesli_core::{
error::{ConException, ProtocolError},
methods::{
Bit, FieldValue, Long, Longlong, Longstr, Octet, Short, Shortstr, Table, TableFieldName,
@ -55,8 +55,8 @@ pub fn other_fail<E, S: Into<String>>(msg: S) -> impl FnOnce(E) -> Err<TransErro
macro_rules! fail {
($cause:expr) => {
return Err(nom::Err::Failure(
::amqp_core::error::ProtocolError::ConException(
::amqp_core::error::ConException::SyntaxError(vec![String::from($cause)]),
::haesli_core::error::ProtocolError::ConException(
::haesli_core::error::ConException::SyntaxError(vec![String::from($cause)]),
)
.into(),
))

View file

@ -1,7 +1,9 @@
use std::io::Write;
use amqp_core::methods::{Bit, Long, Longlong, Longstr, Octet, Short, Shortstr, Table, Timestamp};
use anyhow::Context;
use haesli_core::methods::{
Bit, Long, Longlong, Longstr, Octet, Short, Shortstr, Table, Timestamp,
};
use crate::{error::TransError, methods::FieldValue};

View file

@ -2,7 +2,7 @@
//!
//! Currently only supports PLAIN (see [RFC 4616](https://datatracker.ietf.org/doc/html/rfc4616))
use amqp_core::error::ConException;
use haesli_core::error::ConException;
use crate::error::Result;

View file

@ -1,6 +1,6 @@
use std::collections::HashMap;
use amqp_core::{
use haesli_core::{
connection::ChannelNum,
methods::{ConnectionStart, ConnectionStartOk, FieldValue, Method},
};

View file

@ -25,14 +25,14 @@ async fn main() -> Result<()> {
setup_tracing(&args);
let global_data = amqp_core::GlobalData::default();
let global_data = haesli_core::GlobalData::default();
if args.dashboard {
let global_data = global_data.clone();
tokio::spawn(async move { amqp_dashboard::start_dashboard(global_data).await });
tokio::spawn(async move { haesli_dashboard::start_dashboard(global_data).await });
}
let res = amqp_transport::do_thing_i_guess(global_data, terminate()).await;
let res = haesli_transport::do_thing_i_guess(global_data, terminate()).await;
info!("Bye!");

View file

@ -28,7 +28,7 @@ pub fn main() -> anyhow::Result<()> {
"`yarn check-fmt` did not exist successfully"
);
let frontend = project_root().join("amqp_dashboard/frontend");
let frontend = project_root().join("haesli_dashboard/frontend");
yarn_install(&frontend)?;
println!("$ yarn check-fmt");
let status = Command::new("yarn")

View file

@ -127,13 +127,13 @@ pub fn main() -> anyhow::Result<()> {
.context("src directory path")?
.parent()
.context("xtask root path")?;
let amqp_spec = xtask_root.join("amqp0-9-1.xml");
let haesli_spec = xtask_root.join("amqp0-9-1.xml");
let project_root = xtask_root.parent().context("get project root parent")?;
let transport_generated_path = project_root.join("amqp_transport/src/methods/generated.rs");
let core_generated_path = project_root.join("amqp_core/src/methods/generated.rs");
let transport_generated_path = project_root.join("haesli_transport/src/methods/generated.rs");
let core_generated_path = project_root.join("haesli_core/src/methods/generated.rs");
let content = fs::read_to_string(amqp_spec).context("read amqp spec file")?;
let content = fs::read_to_string(haesli_spec).context("read amqp spec file")?;
let amqp = Amqp::from_str(&content).context("parse amqp spec file")?;
@ -202,7 +202,7 @@ impl Codegen {
self.output,
"pub type {} = {};\n",
domain.name.to_upper_camel_case(),
self.amqp_type_to_rust_type(&domain.kind),
self.haesli_type_to_rust_type(&domain.kind),
)
.ok();
}
@ -266,8 +266,8 @@ pub struct {class_name}{method_name}"
}
}
fn amqp_type_to_rust_type(&self, amqp_type: &str) -> &'static str {
match amqp_type {
fn haesli_type_to_rust_type(&self, haesli_type: &str) -> &'static str {
match haesli_type {
"octet" => "u8",
"short" => "u16",
"long" => "u32",
@ -277,7 +277,7 @@ pub struct {class_name}{method_name}"
"longstr" => "Vec<u8>",
"timestamp" => "u64",
"table" => "super::Table",
_ => unreachable!("invalid type {}", amqp_type),
_ => unreachable!("invalid type {}", haesli_type),
}
}

View file

@ -21,7 +21,7 @@ impl Codegen {
writeln!(
self.output,
"pub mod parse {{
use amqp_core::methods::*;
use haesli_core::methods::*;
use crate::error::TransError;
use crate::methods::parse_helper::*;
use nom::{{branch::alt, bytes::complete::tag}};

View file

@ -9,7 +9,7 @@ impl Codegen {
"
mod random {{
use rand::Rng;
use amqp_core::methods::*;
use haesli_core::methods::*;
use crate::methods::RandomMethod;
"
)

View file

@ -7,7 +7,7 @@ impl Codegen {
writeln!(
self.output,
"pub mod write {{
use amqp_core::methods::*;
use haesli_core::methods::*;
use crate::error::TransError;
use crate::methods::write_helper::*;
use std::io::Write;

View file

@ -21,7 +21,7 @@ pub fn main() -> anyhow::Result<()> {
.status()?;
ensure!(status.success(), "`yarn fmt` did not exist successfully");
let frontend = project_root().join("amqp_dashboard/frontend");
let frontend = project_root().join("haesli_dashboard/frontend");
yarn_install(&frontend)?;
println!("$ yarn fmt");
let status = Command::new("yarn")

View file

@ -15,7 +15,7 @@ pub fn main() -> Result<()> {
.context("cargo build")?;
ensure!(status.success(), "cargo build failed");
let mut amqp_server = Command::new("target/debug/amqp")
let mut haesli_server = Command::new("target/debug/amqp")
.env("RUST_LOG", "trace")
.spawn()
.context("target/debug/amqp run")?;
@ -25,7 +25,7 @@ pub fn main() -> Result<()> {
let test_result = run_js(&test_js_root);
amqp_server.kill().context("killing amqp server")?;
haesli_server.kill().context("killing amqp server")?;
test_result
}