diff --git a/Cargo.lock b/Cargo.lock index 556e2cca..38c9711a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "hotfix-status" -version = "0.0.26" +version = "0.1.0" dependencies = [ "askama", "async-trait", @@ -2056,7 +2056,7 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" dependencies = [ - "toml_edit 0.22.27", + "toml_edit", ] [[package]] @@ -3163,8 +3163,8 @@ checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ "serde", "serde_spanned", - "toml_datetime 0.6.11", - "toml_edit 0.22.27", + "toml_datetime", + "toml_edit", ] [[package]] @@ -3176,15 +3176,6 @@ dependencies = [ "serde", ] -[[package]] -name = "toml_datetime" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bade1c3e902f58d73d3f294cd7f20391c1cb2fbcb643b73566bc773971df91e3" -dependencies = [ - "serde", -] - [[package]] name = "toml_edit" version = "0.22.27" @@ -3194,45 +3185,17 @@ dependencies = [ "indexmap 2.9.0", "serde", "serde_spanned", - "toml_datetime 0.6.11", + "toml_datetime", "toml_write", "winnow", ] -[[package]] -name = "toml_edit" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f23a5f4511b296579b6c83e437fe85fa7ece22e3ec44e45ddb975bcf57c3dd" -dependencies = [ - "indexmap 2.9.0", - "toml_datetime 0.7.0", - "toml_parser", - "toml_writer", - "winnow", -] - -[[package]] -name = "toml_parser" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97200572db069e74c512a14117b296ba0a80a30123fbbb5aa1f4a348f639ca30" -dependencies = [ - "winnow", -] - [[package]] name = "toml_write" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" -[[package]] -name = "toml_writer" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc842091f2def52017664b53082ecbbeb5c7731092bad69d2c63050401dfd64" - [[package]] name = "tower" version = "0.5.2" @@ -3409,15 +3372,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" -[[package]] -name = "utils" -version = "0.0.26" -dependencies = [ - "anyhow", - "clap", - "toml_edit 0.23.1", -] - [[package]] name = "uuid" version = "1.17.0" diff --git a/crates/hotfix-status/CHANGELOG.md b/crates/hotfix-status/CHANGELOG.md index cee43c79..90aca249 100644 --- a/crates/hotfix-status/CHANGELOG.md +++ b/crates/hotfix-status/CHANGELOG.md @@ -15,19 +15,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Other -- Fix initial creation time setting in redb store -- Add check for code formatting -- Add code coverage badge -- Update version to 0.0.21 to release DynamoDB stores -- Prepare for 0.0.19 release -- Update README with Test Requests -- Update README with next steps -- Process backlog of messages when a resend is completed -- Update README -- Nicer API for manipulating groups and example application using repeating groups -- Add badges -- Update crates in preparation for 0.0.11 release -- Switch to internal fork of ferrumfix for message encoding and decoding -- Use fix44 types for message generation -- Prepare project for crates.io publishing -- Initial commit +- initial release \ No newline at end of file diff --git a/crates/hotfix-status/Cargo.toml b/crates/hotfix-status/Cargo.toml index ee30c94e..750ae276 100644 --- a/crates/hotfix-status/Cargo.toml +++ b/crates/hotfix-status/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "hotfix-status" description = "Status endpoints and an option web-based dashboard for the HotFIX engine" -version.workspace = true +version = "0.1.0" authors.workspace = true edition.workspace = true license.workspace = true -readme.workspace = true +readme = "README.md" homepage.workspace = true repository.workspace = true keywords.workspace = true diff --git a/crates/hotfix-status/README.md b/crates/hotfix-status/README.md new file mode 100644 index 00000000..d09a5549 --- /dev/null +++ b/crates/hotfix-status/README.md @@ -0,0 +1,39 @@ +
+ +# hotfix-status + +**Status APIs and UI for the HotFIX engine.** + +
+ +This crate is an add-on for the [HotFIX engine](https://github.com/Validus-Risk-Management/hotfix) +to provide useful APIs about the FIX session state and health. + +Optionally, it also provides a web-based UI to view and manage the session state. + +## Usage + +`hotfix-status` build an `axum` router you can embed in your application in any way you like. + +To build the router, just call `build_router` with the HotFIX session ref: + +```rust +... + +use hotfix_status::build_router; + +... + +async fn start_status_service(session_ref: SessionRef) { + let status_router = build_router(session_ref); + let host_and_port = std::env::var("HOST_AND_PORT").unwrap_or("0.0.0.0:9881".to_string()); + let listener = tokio::net::TcpListener::bind(&host_and_port).await.unwrap(); + + info!("starting status service on http://{host_and_port}"); + axum::serve(listener, status_router).await.unwrap(); +} +``` + +For a full example, check out +the [simple-new-order](https://github.com/Validus-Risk-Management/hotfix/tree/main/examples/simple-new-order) +sample application. diff --git a/crates/hotfix-status/src/lib.rs b/crates/hotfix-status/src/lib.rs index 22afd71c..2611c30f 100644 --- a/crates/hotfix-status/src/lib.rs +++ b/crates/hotfix-status/src/lib.rs @@ -1,5 +1,6 @@ mod api; mod data_provider; +#[cfg(feature = "ui")] mod error; #[cfg(feature = "ui")] mod ui; @@ -29,5 +30,7 @@ pub fn build_router(session_ref: SessionRef) -> Router { pub fn build_router(session_ref: SessionRef) -> Router { let data_provider = SessionDataProvider { session_ref }; let state = AppState { data_provider }; - Router::new().nest("/api", build_api_router(state)) + Router::new() + .nest("/api", build_api_router()) + .with_state(state) } diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml deleted file mode 100644 index 280e9871..00000000 --- a/crates/utils/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "utils" -version.workspace = true -authors.workspace = true -edition.workspace = true -license.workspace = true -readme.workspace = true -homepage.workspace = true -repository.workspace = true -keywords.workspace = true -categories.workspace = true -publish = false - -[[bin]] -name = "update-version" -path = "src/update_version.rs" - -[dependencies] -anyhow = { workspace = true } -clap = { version = "4.4.8", features = ["derive"] } -toml_edit = "0.23" diff --git a/crates/utils/src/update_version.rs b/crates/utils/src/update_version.rs deleted file mode 100644 index eb89423e..00000000 --- a/crates/utils/src/update_version.rs +++ /dev/null @@ -1,84 +0,0 @@ -use std::fs; -use std::path::{Path, PathBuf}; - -use anyhow::Result; -use clap::Parser; -use toml_edit::{DocumentMut, Formatted, value}; - -#[derive(Parser, Debug)] -#[command(author, version, about, long_about = None)] -struct Args { - #[arg(long)] - hotfix_version: String, -} - -fn main() -> Result<()> { - let args = Args::parse(); - let crates = get_crate_dirs()?; - update_workspace(&args.hotfix_version)?; - - for c in crates { - update_crate(c, &args.hotfix_version)?; - } - - Ok(()) -} - -fn update_workspace(version: &str) -> Result<()> { - let path = PathBuf::from("Cargo.toml"); - let mut doc = parse_cargo_toml(path.as_path())?; - doc["workspace"]["package"]["version"] = value(version); - - fs::write(path, doc.to_string())?; - Ok(()) -} - -fn update_crate(crate_path: PathBuf, version: &str) -> Result<()> { - let path = crate_path.join("Cargo.toml"); - let mut doc = parse_cargo_toml(path.as_path())?; - - for section in ["dependencies", "dev-dependencies", "build-dependencies"] { - if let Some(deps) = doc.get_mut(section) { - let table = deps.as_table_mut().unwrap(); - for (name, dep) in table.iter_mut() { - if name.starts_with("hotfix") { - println!("updating {name} in {path:?} to {version}"); - if let Some(dep_table) = dep.as_inline_table_mut() { - if let Some(v) = dep_table.get_mut("version") { - *v = toml_edit::Value::String(Formatted::new(version.to_string())); - } - } else { - *dep = value(version); - } - } - } - } - } - - fs::write(path, doc.to_string())?; - Ok(()) -} - -fn parse_cargo_toml(cargo_toml_path: &Path) -> Result { - let contents = fs::read_to_string(cargo_toml_path)?; - Ok(contents.parse()?) -} - -fn get_crate_dirs() -> Result> { - let crate_dir = "./crates"; - let mut crates = Vec::new(); - for entry in fs::read_dir(crate_dir)? { - let entry = entry?; - let path = entry.path(); - - // Check if it's a directory and the name starts with "hotfix" - if path.is_dir() - && let Some(name) = path.file_name().and_then(|n| n.to_str()) - && name.starts_with("hotfix") - { - crates.push(path); - } - } - - Ok(crates) -} diff --git a/publish.sh b/publish.sh deleted file mode 100755 index 63a9359e..00000000 --- a/publish.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -cargo publish -p hotfix-dictionary -cargo publish -p hotfix-derive -cargo publish -p hotfix-codegen -cargo publish -p hotfix-message -cargo publish -p hotfix