diff --git a/.gitattributes b/.gitattributes index e913bff..1cfae69 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,2 @@ -amqp_core/src/methods/generated.rs linguist-generated -amqp_transport/src/methods/generated.rs linguist-generated \ No newline at end of file +haesli_core/src/methods/generated.rs linguist-generated +haesli_transport/src/methods/generated.rs linguist-generated \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index b996d31..4c6a23f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/Cargo.toml b/Cargo.toml index a98d56b..327a416 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/README.md b/README.md index e9a6d56..208d3a7 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/amqp_messaging/src/methods/mod.rs b/amqp_messaging/src/methods/mod.rs deleted file mode 100644 index 8b5a0e7..0000000 --- a/amqp_messaging/src/methods/mod.rs +++ /dev/null @@ -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 { - 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) -} diff --git a/amqp_core/Cargo.toml b/haesli_core/Cargo.toml similarity index 81% rename from amqp_core/Cargo.toml rename to haesli_core/Cargo.toml index 772bd12..ecc7b90 100644 --- a/amqp_core/Cargo.toml +++ b/haesli_core/Cargo.toml @@ -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" diff --git a/amqp_core/src/connection.rs b/haesli_core/src/connection.rs similarity index 100% rename from amqp_core/src/connection.rs rename to haesli_core/src/connection.rs diff --git a/amqp_core/src/consumer.rs b/haesli_core/src/consumer.rs similarity index 100% rename from amqp_core/src/consumer.rs rename to haesli_core/src/consumer.rs diff --git a/amqp_core/src/error.rs b/haesli_core/src/error.rs similarity index 100% rename from amqp_core/src/error.rs rename to haesli_core/src/error.rs diff --git a/amqp_core/src/lib.rs b/haesli_core/src/lib.rs similarity index 100% rename from amqp_core/src/lib.rs rename to haesli_core/src/lib.rs diff --git a/amqp_core/src/macros.rs b/haesli_core/src/macros.rs similarity index 89% rename from amqp_core/src/macros.rs rename to haesli_core/src/macros.rs index 2500ef9..9b74e7d 100644 --- a/amqp_core/src/macros.rs +++ b/haesli_core/src/macros.rs @@ -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()) }; } diff --git a/amqp_core/src/message.rs b/haesli_core/src/message.rs similarity index 100% rename from amqp_core/src/message.rs rename to haesli_core/src/message.rs diff --git a/amqp_core/src/methods/generated.rs b/haesli_core/src/methods/generated.rs similarity index 100% rename from amqp_core/src/methods/generated.rs rename to haesli_core/src/methods/generated.rs diff --git a/amqp_core/src/methods/mod.rs b/haesli_core/src/methods/mod.rs similarity index 100% rename from amqp_core/src/methods/mod.rs rename to haesli_core/src/methods/mod.rs diff --git a/amqp_core/src/queue.rs b/haesli_core/src/queue.rs similarity index 96% rename from amqp_core/src/queue.rs rename to haesli_core/src/queue.rs index 4d9c924..5c3546f 100644 --- a/amqp_core/src/queue.rs +++ b/haesli_core/src/queue.rs @@ -49,7 +49,7 @@ impl Display for QueueName { pub struct QueueInner { pub id: QueueId, pub name: QueueName, - pub messages: amqp_datastructure::MessageQueue, + pub messages: haesli_datastructure::MessageQueue, pub durable: bool, pub exclusive: Option, /// Whether the queue will automatically be deleted when no consumers uses it anymore. diff --git a/amqp_dashboard/Cargo.toml b/haesli_dashboard/Cargo.toml similarity index 88% rename from amqp_dashboard/Cargo.toml rename to haesli_dashboard/Cargo.toml index 084075f..dc35000 100644 --- a/amqp_dashboard/Cargo.toml +++ b/haesli_dashboard/Cargo.toml @@ -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" diff --git a/amqp_dashboard/build.rs b/haesli_dashboard/build.rs similarity index 100% rename from amqp_dashboard/build.rs rename to haesli_dashboard/build.rs diff --git a/amqp_dashboard/frontend/.gitignore b/haesli_dashboard/frontend/.gitignore similarity index 100% rename from amqp_dashboard/frontend/.gitignore rename to haesli_dashboard/frontend/.gitignore diff --git a/amqp_dashboard/frontend/.prettierignore b/haesli_dashboard/frontend/.prettierignore similarity index 100% rename from amqp_dashboard/frontend/.prettierignore rename to haesli_dashboard/frontend/.prettierignore diff --git a/amqp_dashboard/frontend/.prettierrc.json b/haesli_dashboard/frontend/.prettierrc.json similarity index 100% rename from amqp_dashboard/frontend/.prettierrc.json rename to haesli_dashboard/frontend/.prettierrc.json diff --git a/amqp_dashboard/frontend/README.md b/haesli_dashboard/frontend/README.md similarity index 100% rename from amqp_dashboard/frontend/README.md rename to haesli_dashboard/frontend/README.md diff --git a/amqp_dashboard/frontend/package.json b/haesli_dashboard/frontend/package.json similarity index 100% rename from amqp_dashboard/frontend/package.json rename to haesli_dashboard/frontend/package.json diff --git a/amqp_dashboard/frontend/public/favicon.ico b/haesli_dashboard/frontend/public/favicon.ico similarity index 100% rename from amqp_dashboard/frontend/public/favicon.ico rename to haesli_dashboard/frontend/public/favicon.ico diff --git a/amqp_dashboard/frontend/public/index.html b/haesli_dashboard/frontend/public/index.html similarity index 100% rename from amqp_dashboard/frontend/public/index.html rename to haesli_dashboard/frontend/public/index.html diff --git a/amqp_dashboard/frontend/public/logo192.png b/haesli_dashboard/frontend/public/logo192.png similarity index 100% rename from amqp_dashboard/frontend/public/logo192.png rename to haesli_dashboard/frontend/public/logo192.png diff --git a/amqp_dashboard/frontend/public/logo512.png b/haesli_dashboard/frontend/public/logo512.png similarity index 100% rename from amqp_dashboard/frontend/public/logo512.png rename to haesli_dashboard/frontend/public/logo512.png diff --git a/amqp_dashboard/frontend/public/manifest.json b/haesli_dashboard/frontend/public/manifest.json similarity index 100% rename from amqp_dashboard/frontend/public/manifest.json rename to haesli_dashboard/frontend/public/manifest.json diff --git a/amqp_dashboard/frontend/public/robots.txt b/haesli_dashboard/frontend/public/robots.txt similarity index 100% rename from amqp_dashboard/frontend/public/robots.txt rename to haesli_dashboard/frontend/public/robots.txt diff --git a/amqp_dashboard/frontend/src/app.css b/haesli_dashboard/frontend/src/app.css similarity index 100% rename from amqp_dashboard/frontend/src/app.css rename to haesli_dashboard/frontend/src/app.css diff --git a/amqp_dashboard/frontend/src/app.tsx b/haesli_dashboard/frontend/src/app.tsx similarity index 92% rename from amqp_dashboard/frontend/src/app.tsx rename to haesli_dashboard/frontend/src/app.tsx index 4d07d6a..e914eda 100644 --- a/amqp_dashboard/frontend/src/app.tsx +++ b/haesli_dashboard/frontend/src/app.tsx @@ -10,7 +10,7 @@ const App = () => { return (
-

AMQP Dashboard

+

Haesli Dashboard

diff --git a/amqp_dashboard/frontend/src/components/data-page.tsx b/haesli_dashboard/frontend/src/components/data-page.tsx similarity index 100% rename from amqp_dashboard/frontend/src/components/data-page.tsx rename to haesli_dashboard/frontend/src/components/data-page.tsx diff --git a/amqp_dashboard/frontend/src/components/table.tsx b/haesli_dashboard/frontend/src/components/table.tsx similarity index 100% rename from amqp_dashboard/frontend/src/components/table.tsx rename to haesli_dashboard/frontend/src/components/table.tsx diff --git a/amqp_dashboard/frontend/src/index.css b/haesli_dashboard/frontend/src/index.css similarity index 100% rename from amqp_dashboard/frontend/src/index.css rename to haesli_dashboard/frontend/src/index.css diff --git a/amqp_dashboard/frontend/src/index.tsx b/haesli_dashboard/frontend/src/index.tsx similarity index 100% rename from amqp_dashboard/frontend/src/index.tsx rename to haesli_dashboard/frontend/src/index.tsx diff --git a/amqp_dashboard/frontend/src/types.ts b/haesli_dashboard/frontend/src/types.ts similarity index 100% rename from amqp_dashboard/frontend/src/types.ts rename to haesli_dashboard/frontend/src/types.ts diff --git a/amqp_dashboard/frontend/tsconfig.json b/haesli_dashboard/frontend/tsconfig.json similarity index 100% rename from amqp_dashboard/frontend/tsconfig.json rename to haesli_dashboard/frontend/tsconfig.json diff --git a/amqp_dashboard/frontend/yarn.lock b/haesli_dashboard/frontend/yarn.lock similarity index 100% rename from amqp_dashboard/frontend/yarn.lock rename to haesli_dashboard/frontend/yarn.lock diff --git a/amqp_dashboard/src/archive.rs b/haesli_dashboard/src/archive.rs similarity index 100% rename from amqp_dashboard/src/archive.rs rename to haesli_dashboard/src/archive.rs diff --git a/amqp_dashboard/src/lib.rs b/haesli_dashboard/src/lib.rs similarity index 99% rename from amqp_dashboard/src/lib.rs rename to haesli_dashboard/src/lib.rs index a6334bb..9ef56d1 100644 --- a/amqp_dashboard/src/lib.rs +++ b/haesli_dashboard/src/lib.rs @@ -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}; diff --git a/amqp_datastructure/Cargo.toml b/haesli_datastructure/Cargo.toml similarity index 84% rename from amqp_datastructure/Cargo.toml rename to haesli_datastructure/Cargo.toml index 0cd3b52..43dfa5f 100644 --- a/amqp_datastructure/Cargo.toml +++ b/haesli_datastructure/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "amqp_datastructure" +name = "haesli_datastructure" version = "0.1.0" edition = "2021" diff --git a/amqp_datastructure/src/lib.rs b/haesli_datastructure/src/lib.rs similarity index 100% rename from amqp_datastructure/src/lib.rs rename to haesli_datastructure/src/lib.rs diff --git a/amqp_datastructure/src/message_queue.rs b/haesli_datastructure/src/message_queue.rs similarity index 100% rename from amqp_datastructure/src/message_queue.rs rename to haesli_datastructure/src/message_queue.rs diff --git a/amqp_messaging/Cargo.toml b/haesli_messaging/Cargo.toml similarity index 67% rename from amqp_messaging/Cargo.toml rename to haesli_messaging/Cargo.toml index ee871e3..2506934 100644 --- a/amqp_messaging/Cargo.toml +++ b/haesli_messaging/Cargo.toml @@ -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"] } diff --git a/amqp_messaging/src/lib.rs b/haesli_messaging/src/lib.rs similarity index 79% rename from amqp_messaging/src/lib.rs rename to haesli_messaging/src/lib.rs index 23b24ab..84ed7b6 100644 --- a/amqp_messaging/src/lib.rs +++ b/haesli_messaging/src/lib.rs @@ -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; diff --git a/amqp_messaging/src/methods/consume.rs b/haesli_messaging/src/methods/consume.rs similarity index 92% rename from amqp_messaging/src/methods/consume.rs rename to haesli_messaging/src/methods/consume.rs index 92f1b91..1cf2260 100644 --- a/amqp_messaging/src/methods/consume.rs +++ b/haesli_messaging/src/methods/consume.rs @@ -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 } = 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 }; diff --git a/haesli_messaging/src/methods/mod.rs b/haesli_messaging/src/methods/mod.rs new file mode 100644 index 0000000..1f08d2e --- /dev/null +++ b/haesli_messaging/src/methods/mod.rs @@ -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 { + 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) +} diff --git a/amqp_messaging/src/methods/publish.rs b/haesli_messaging/src/methods/publish.rs similarity index 93% rename from amqp_messaging/src/methods/publish.rs rename to haesli_messaging/src/methods/publish.rs index 4a1c0dd..3bb71f5 100644 --- a/amqp_messaging/src/methods/publish.rs +++ b/haesli_messaging/src/methods/publish.rs @@ -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(); diff --git a/amqp_messaging/src/methods/queue.rs b/haesli_messaging/src/methods/queue.rs similarity index 93% rename from amqp_messaging/src/methods/queue.rs rename to haesli_messaging/src/methods/queue.rs index 2752ecf..7986d1f 100644 --- a/amqp_messaging/src/methods/queue.rs +++ b/haesli_messaging/src/methods/queue.rs @@ -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 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 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 } pub async fn bind(_channel_handle: Channel, _queue_bind: QueueBind) -> Result { - amqp_todo!(); + haesli_todo!(); } fn bind_queue(global_data: GlobalData, _exchange: (), routing_key: Arc) -> Result<()> { diff --git a/amqp_messaging/src/queue_worker.rs b/haesli_messaging/src/queue_worker.rs similarity index 99% rename from amqp_messaging/src/queue_worker.rs rename to haesli_messaging/src/queue_worker.rs index 16a1a78..06e8351 100644 --- a/amqp_messaging/src/queue_worker.rs +++ b/haesli_messaging/src/queue_worker.rs @@ -1,6 +1,6 @@ use std::borrow::Borrow; -use amqp_core::{ +use haesli_core::{ connection::ConnectionEvent, consumer::Consumer, message::Message, diff --git a/amqp_transport/Cargo.toml b/haesli_transport/Cargo.toml similarity index 80% rename from amqp_transport/Cargo.toml rename to haesli_transport/Cargo.toml index a842ee9..0c5807f 100644 --- a/amqp_transport/Cargo.toml +++ b/haesli_transport/Cargo.toml @@ -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" diff --git a/amqp_transport/benches/parser.rs b/haesli_transport/benches/parser.rs similarity index 93% rename from amqp_transport/benches/parser.rs rename to haesli_transport/benches/parser.rs index cd78e87..5b32926 100644 --- a/amqp_transport/benches/parser.rs +++ b/haesli_transport/benches/parser.rs @@ -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 { diff --git a/amqp_transport/src/connection.rs b/haesli_transport/src/connection.rs similarity index 98% rename from amqp_transport/src/connection.rs rename to haesli_transport/src/connection.rs index 15022f6..9cb92ef 100644 --- a/amqp_transport/src/connection.rs +++ b/haesli_transport/src/connection.rs @@ -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()) diff --git a/amqp_transport/src/error.rs b/haesli_transport/src/error.rs similarity index 81% rename from amqp_transport/src/error.rs rename to haesli_transport/src/error.rs index 28b6a0c..cf1158c 100644 --- a/amqp_transport/src/error.rs +++ b/haesli_transport/src/error.rs @@ -1,6 +1,6 @@ use std::io::Error; -pub use amqp_core::error::{ConException, ProtocolError}; +pub use haesli_core::error::{ConException, ProtocolError}; type StdResult = std::result::Result; @@ -20,7 +20,7 @@ impl From for TransError { } } -impl From for TransError { +impl From for TransError { fn from(err: ConException) -> Self { Self::Protocol(ProtocolError::ConException(err)) } diff --git a/amqp_transport/src/frame.rs b/haesli_transport/src/frame.rs similarity index 99% rename from amqp_transport/src/frame.rs rename to haesli_transport/src/frame.rs index ddb4d79..56583aa 100644 --- a/amqp_transport/src/frame.rs +++ b/haesli_transport/src/frame.rs @@ -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 { mod content_header_write { use std::io::Write; - use amqp_core::{ + use haesli_core::{ connection::ContentHeader, methods::{ FieldValue::{FieldTable, ShortShortUInt, ShortString, Timestamp}, diff --git a/amqp_transport/src/lib.rs b/haesli_transport/src/lib.rs similarity index 94% rename from amqp_transport/src/lib.rs rename to haesli_transport/src/lib.rs index 17822ca..2dae1ec 100644 --- a/amqp_transport/src/lib.rs +++ b/haesli_transport/src/lib.rs @@ -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(), diff --git a/amqp_transport/src/methods/generated.rs b/haesli_transport/src/methods/generated.rs similarity index 99% rename from amqp_transport/src/methods/generated.rs rename to haesli_transport/src/methods/generated.rs index 82fda42..041cd58 100644 --- a/amqp_transport/src/methods/generated.rs +++ b/haesli_transport/src/methods/generated.rs @@ -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; diff --git a/amqp_transport/src/methods/mod.rs b/haesli_transport/src/methods/mod.rs similarity index 99% rename from amqp_transport/src/methods/mod.rs rename to haesli_transport/src/methods/mod.rs index 4153db1..d8c2366 100644 --- a/amqp_transport/src/methods/mod.rs +++ b/haesli_transport/src/methods/mod.rs @@ -1,4 +1,4 @@ -use amqp_core::{ +use haesli_core::{ error::ConException, methods::{FieldValue, Method, Table}, }; diff --git a/amqp_transport/src/methods/parse_helper.rs b/haesli_transport/src/methods/parse_helper.rs similarity index 97% rename from amqp_transport/src/methods/parse_helper.rs rename to haesli_transport/src/methods/parse_helper.rs index 56a24fb..6b2455b 100644 --- a/amqp_transport/src/methods/parse_helper.rs +++ b/haesli_transport/src/methods/parse_helper.rs @@ -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>(msg: S) -> impl FnOnce(E) -> Err { 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(), )) diff --git a/amqp_transport/src/methods/tests.rs b/haesli_transport/src/methods/tests.rs similarity index 100% rename from amqp_transport/src/methods/tests.rs rename to haesli_transport/src/methods/tests.rs diff --git a/amqp_transport/src/methods/write_helper.rs b/haesli_transport/src/methods/write_helper.rs similarity index 98% rename from amqp_transport/src/methods/write_helper.rs rename to haesli_transport/src/methods/write_helper.rs index 69add00..e43ae95 100644 --- a/amqp_transport/src/methods/write_helper.rs +++ b/haesli_transport/src/methods/write_helper.rs @@ -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}; diff --git a/amqp_transport/src/sasl.rs b/haesli_transport/src/sasl.rs similarity index 96% rename from amqp_transport/src/sasl.rs rename to haesli_transport/src/sasl.rs index 89a2a5e..74afdb1 100644 --- a/amqp_transport/src/sasl.rs +++ b/haesli_transport/src/sasl.rs @@ -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; diff --git a/amqp_transport/src/tests.rs b/haesli_transport/src/tests.rs similarity index 99% rename from amqp_transport/src/tests.rs rename to haesli_transport/src/tests.rs index c44412c..d6956ff 100644 --- a/amqp_transport/src/tests.rs +++ b/haesli_transport/src/tests.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use amqp_core::{ +use haesli_core::{ connection::ChannelNum, methods::{ConnectionStart, ConnectionStartOk, FieldValue, Method}, }; diff --git a/src/main.rs b/src/main.rs index 2ce6942..3da9bbc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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!"); diff --git a/xtask/src/check_fmt.rs b/xtask/src/check_fmt.rs index 8e861b2..c4758e4 100644 --- a/xtask/src/check_fmt.rs +++ b/xtask/src/check_fmt.rs @@ -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") diff --git a/xtask/src/codegen/mod.rs b/xtask/src/codegen/mod.rs index 3143594..251b5be 100644 --- a/xtask/src/codegen/mod.rs +++ b/xtask/src/codegen/mod.rs @@ -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", "timestamp" => "u64", "table" => "super::Table", - _ => unreachable!("invalid type {}", amqp_type), + _ => unreachable!("invalid type {}", haesli_type), } } diff --git a/xtask/src/codegen/parser.rs b/xtask/src/codegen/parser.rs index 1914953..721bde9 100644 --- a/xtask/src/codegen/parser.rs +++ b/xtask/src/codegen/parser.rs @@ -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}}; diff --git a/xtask/src/codegen/random.rs b/xtask/src/codegen/random.rs index 06226fb..7819207 100644 --- a/xtask/src/codegen/random.rs +++ b/xtask/src/codegen/random.rs @@ -9,7 +9,7 @@ impl Codegen { " mod random {{ use rand::Rng; -use amqp_core::methods::*; +use haesli_core::methods::*; use crate::methods::RandomMethod; " ) diff --git a/xtask/src/codegen/write.rs b/xtask/src/codegen/write.rs index 8da7beb..e22ede9 100644 --- a/xtask/src/codegen/write.rs +++ b/xtask/src/codegen/write.rs @@ -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; diff --git a/xtask/src/fmt.rs b/xtask/src/fmt.rs index e59f90a..4107e5d 100644 --- a/xtask/src/fmt.rs +++ b/xtask/src/fmt.rs @@ -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") diff --git a/xtask/src/test_js.rs b/xtask/src/test_js.rs index ddfdc9f..b8db101 100644 --- a/xtask/src/test_js.rs +++ b/xtask/src/test_js.rs @@ -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 }