66//! The initiator establishes the transport layer connection with
77//! the peer, and sends the initial Logon (35=A) message. For transport,
88//! `HotFIX` supports plain TCP and encrypted TLS over TCP connections.
9- use anyhow:: Result ;
109use std:: time:: Duration ;
1110use tokio:: sync:: watch;
1211use tokio:: time:: sleep;
@@ -15,7 +14,7 @@ use tracing::{debug, warn};
1514use crate :: application:: Application ;
1615use crate :: config:: SessionConfig ;
1716use crate :: message:: { InboundMessage , OutboundMessage } ;
18- use crate :: session:: error:: { SendError , SendOutcome } ;
17+ use crate :: session:: error:: { SendError , SendOutcome , SessionCreationError } ;
1918use crate :: session:: { InternalSessionRef , SessionHandle } ;
2019use crate :: store:: MessageStore ;
2120use crate :: transport:: connect;
@@ -32,7 +31,7 @@ impl<Outbound: OutboundMessage> Initiator<Outbound> {
3231 config : SessionConfig ,
3332 application : impl Application < Inbound , Outbound > ,
3433 store : impl MessageStore + ' static ,
35- ) -> Result < Self > {
34+ ) -> Result < Self , SessionCreationError > {
3635 let session_ref = InternalSessionRef :: new ( config. clone ( ) , application, store) ?;
3736 let ( completion_tx, completion_rx) = watch:: channel ( false ) ;
3837
@@ -76,9 +75,11 @@ impl<Outbound: OutboundMessage> Initiator<Outbound> {
7675 self . session_handle . clone ( )
7776 }
7877
79- pub async fn shutdown ( self , reconnect : bool ) -> Result < ( ) > {
78+ pub async fn shutdown ( self , reconnect : bool ) -> Result < ( ) , SendError > {
8079 self . session_handle . shutdown ( reconnect) . await ?;
81- tokio:: time:: timeout ( Duration :: from_secs ( 5 ) , self . wait_for_shutdown ( ) ) . await ?;
80+ tokio:: time:: timeout ( Duration :: from_secs ( 5 ) , self . wait_for_shutdown ( ) )
81+ . await
82+ . map_err ( |_| SendError :: SessionGone ) ?;
8283
8384 Ok ( ( ) )
8485 }
0 commit comments