Skip to content

Commit cec198b

Browse files
committed
Update example app with new terminology for web interface
1 parent 9886cfa commit cec198b

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

crates/hotfix/src/session.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,15 +821,18 @@ impl<A: Application<M>, M: FixMessage, S: MessageStore> Session<A, M, S> {
821821
match request {
822822
AdminRequest::InitiateGracefulShutdown { reconnect } => {
823823
// TODO: revisit logout & shutdown flows once logout timeouts are implemented
824+
warn!("initiating shutdown on request from admin..");
824825
self.logout_and_terminate("shutdown requested").await;
825826
self.state = SessionState::new_disconnected(reconnect, "shutdown requested");
826827
}
827828
AdminRequest::RequestSessionInfo(responder) => {
829+
info!("session info requested");
828830
if responder.send(self.get_session_info()).is_err() {
829831
error!("failed to respond to session info request");
830832
}
831833
}
832834
AdminRequest::ResetSequenceNumbersOnNextLogon => {
835+
warn!("resetting sequence numbers on next logon");
833836
self.reset_on_next_logon = true;
834837
}
835838
}

examples/simple-new-order/src/main.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use hotfix::initiator::Initiator;
1010
use hotfix::message::fix44;
1111
use hotfix::session::SessionHandle;
1212
use hotfix::store::mongodb::Client;
13-
use hotfix_web::build_router;
13+
use hotfix_web::{RouterConfig, build_router_with_config};
1414
use std::path::Path;
1515
use tokio::select;
1616
use tokio::task::spawn_blocking;
@@ -66,7 +66,7 @@ async fn main() {
6666
let initiator = start_session(&args.config, &db_config, app).await;
6767

6868
let status_service_token = CancellationToken::new();
69-
tokio::spawn(start_status_service(
69+
tokio::spawn(start_web_service(
7070
initiator.session_handle(),
7171
status_service_token.child_token(),
7272
));
@@ -153,18 +153,21 @@ async fn start_session(
153153
}
154154
}
155155

156-
async fn start_status_service(
156+
async fn start_web_service(
157157
session_handle: SessionHandle<Message>,
158158
cancellation_token: CancellationToken,
159159
) {
160-
let status_router = build_router(session_handle);
160+
let config = RouterConfig {
161+
enable_admin_endpoints: true,
162+
};
163+
let router = build_router_with_config(session_handle, config);
161164
let host_and_port = std::env::var("HOST_AND_PORT").unwrap_or("0.0.0.0:9881".to_string());
162165
let listener = tokio::net::TcpListener::bind(&host_and_port).await.unwrap();
163166

164-
info!("starting status service on http://{host_and_port}");
167+
info!("starting web interface on http://{host_and_port}");
165168

166169
select! {
167-
result = axum::serve(listener, status_router) => {
170+
result = axum::serve(listener, router) => {
168171
if let Err(e) = result {
169172
tracing::error!("status service error: {}", e);
170173
}

0 commit comments

Comments
 (0)