pub struct SessionConfig {Show 19 fields
pub sender_comp_id: CompId,
pub target_comp_id: CompId,
pub begin_string: String,
pub heartbeat_interval: Duration,
pub reset_on_logon: bool,
pub reset_on_logout: bool,
pub reset_on_disconnect: bool,
pub max_message_size: usize,
pub logon_timeout: Duration,
pub logout_timeout: Duration,
pub validate_checksum: bool,
pub validate_length: bool,
pub sending_time_tolerance: Duration,
pub resend_timeout: Duration,
pub max_resend_requests: u32,
pub sender_sub_id: Option<String>,
pub target_sub_id: Option<String>,
pub sender_location_id: Option<String>,
pub target_location_id: Option<String>,
}Expand description
Configuration for a FIX session.
Construct one with SessionConfigBuilder, which validates every knob.
The fields are public so a configuration can also be assembled or adjusted
directly; SessionConfig::validate then says whether the result is
usable, and ironfix-engine calls it before dialling.
Fields§
§sender_comp_id: CompIdSender CompID (tag 49).
target_comp_id: CompIdTarget CompID (tag 56).
begin_string: StringFIX version BeginString, tag 8 (e.g. FIX.4.4).
1..=MAX_ID_LEN bytes of printable ASCII except =. Whether the
version can actually be framed is a separate question, answered by
ironfix-engine.
heartbeat_interval: DurationHeartbeat interval, HeartBtInt (108).
Whole seconds, from MIN_HEARTBEAT_INTERVAL_SECS to
MAX_HEARTBEAT_INTERVAL_SECS. Duration::ZERO is the legal
HeartBtInt = 0 case and disables heartbeating entirely.
reset_on_logon: boolWhether to set ResetSeqNumFlag (141) on the outbound Logon.
reset_on_logout: boolWhether to reset sequence numbers after a graceful Logout.
reset_on_disconnect: boolWhether to reset sequence numbers when the session disconnects.
max_message_size: usizeMaximum accepted message size, in bytes.
From MIN_MESSAGE_SIZE_LIMIT to MAX_MESSAGE_SIZE_LIMIT. Also the
per-connection buffering ceiling of the codec.
logon_timeout: DurationHow long to wait for the Logon acknowledgement.
Non-zero, at most MAX_TIMEOUT.
logout_timeout: DurationHow long to wait for the Logout acknowledgement.
Non-zero, at most MAX_TIMEOUT.
validate_checksum: boolWhether to validate the CheckSum (10) of inbound messages.
validate_length: boolWhether to validate incoming message length.
sending_time_tolerance: DurationLargest difference tolerated, in either direction, between an inbound
message’s SendingTime (52) and the local clock.
Units: wall-clock duration. Range: any duration; Duration::ZERO
disables SendingTime validation entirely, including the presence and
format checks. Default: 120 seconds.
The default matches the tolerance FIX engines have converged on
(QuickFIX’s MaxLatency) and is the interval it is worth choosing:
a host synchronised by NTP stays within milliseconds of true time, so
two minutes is orders of magnitude more slack than a healthy peer ever
needs, while a host that is not synchronised at all drifts past two
minutes within days. Anything much tighter starts rejecting sessions
over ordinary drift and queueing latency; anything much looser stops
distinguishing a wrong clock from a right one.
resend_timeout: DurationHow long an outstanding ResendRequest (2) may make no progress before
it is retried, and eventually abandoned.
Units: wall-clock duration, measured from the moment the request was sent and restarted by every request that follows it. Any in-sequence message clears the outstanding request altogether, so this measures a gap that is not being filled at all, not a slow replay. Range: any duration; a value below the engine’s 100 ms reactor tick simply retries on the next tick. Default: 10 seconds.
max_resend_requests: u32Maximum number of ResendRequest (2) messages sent for one gap,
counting the first.
Once they are spent the session is ended with a Logout rather than left
waiting for a peer that is not answering. Range: 1 and above; 0 is read
as 1, because the first request is unconditional. Default: 3, which
with the default SessionConfig::resend_timeout bounds an
unrecoverable gap at 30 seconds plus the logout handshake.
Read it through SessionConfig::resend_attempt_limit, which applies
the lower bound.
sender_sub_id: Option<String>Optional sender sub ID (tag 50), 1..=MAX_ID_LEN bytes when set.
target_sub_id: Option<String>Optional target sub ID (tag 57), 1..=MAX_ID_LEN bytes when set.
sender_location_id: Option<String>Optional sender location ID (tag 142), 1..=MAX_ID_LEN bytes when set.
target_location_id: Option<String>Optional target location ID (tag 143), 1..=MAX_ID_LEN bytes when set.
Implementations§
Source§impl SessionConfig
impl SessionConfig
Sourcepub fn new(
sender_comp_id: CompId,
target_comp_id: CompId,
begin_string: impl Into<String>,
) -> SessionConfig
pub fn new( sender_comp_id: CompId, target_comp_id: CompId, begin_string: impl Into<String>, ) -> SessionConfig
Creates a session configuration with the documented defaults: a 30 s heartbeat, 10 s handshake timeouts, a 1 MiB message limit, checksum and length validation on, and no sequence resets.
This applies defaults; it does not validate. begin_string is the one
argument that can be malformed — call SessionConfig::validate, or
build through SessionConfigBuilder, to find out before the session
dials.
§Arguments
sender_comp_id- The sender CompID (tag 49)target_comp_id- The target CompID (tag 56)begin_string- TheBeginString(tag 8), e.g.FIX.4.4
Sourcepub fn validate(&self) -> Result<(), SessionConfigError>
pub fn validate(&self) -> Result<(), SessionConfigError>
Checks every knob against the ranges documented on the module.
The CompIDs are not re-checked: CompId validates its charset and
length at construction, so an illegal one is unrepresentable.
Duration::ZERO passes as a heartbeat interval — it is the legal
HeartBtInt = 0. Only SessionConfigBuilder requires that case to
be opted into by name.
§Errors
Returns the first SessionConfigError found: an empty, oversized or
non-encodable identity string, a fractional or out-of-range heartbeat
interval, a zero or excessive handshake timeout, or a message-size
limit outside MIN_MESSAGE_SIZE_LIMIT..=MAX_MESSAGE_SIZE_LIMIT.
Sourcepub const fn with_heartbeat_interval(self, interval: Duration) -> SessionConfig
pub const fn with_heartbeat_interval(self, interval: Duration) -> SessionConfig
Sets the heartbeat interval, HeartBtInt (108).
Whole seconds, MIN_HEARTBEAT_INTERVAL_SECS..=MAX_HEARTBEAT_INTERVAL_SECS,
or Duration::ZERO to disable heartbeating. Checked by
SessionConfig::validate, not here.
Sourcepub const fn with_reset_on_logon(self, reset: bool) -> SessionConfig
pub const fn with_reset_on_logon(self, reset: bool) -> SessionConfig
Sets whether the outbound Logon carries ResetSeqNumFlag (141) = Y.
Sourcepub const fn with_max_message_size(self, size: usize) -> SessionConfig
pub const fn with_max_message_size(self, size: usize) -> SessionConfig
Sets the maximum accepted message size, in bytes.
MIN_MESSAGE_SIZE_LIMIT..=MAX_MESSAGE_SIZE_LIMIT. Checked by
SessionConfig::validate, not here.
Sourcepub const fn with_logon_timeout(self, timeout: Duration) -> SessionConfig
pub const fn with_logon_timeout(self, timeout: Duration) -> SessionConfig
Sets how long to wait for the Logon acknowledgement.
Non-zero, at most MAX_TIMEOUT. Checked by
SessionConfig::validate, not here.
Sourcepub fn with_sender_sub_id(self, sub_id: impl Into<String>) -> SessionConfig
pub fn with_sender_sub_id(self, sub_id: impl Into<String>) -> SessionConfig
Sets the sender sub ID (tag 50).
1..=MAX_ID_LEN bytes of printable ASCII except =. Checked by
SessionConfig::validate, not here.
Sourcepub fn with_target_sub_id(self, sub_id: impl Into<String>) -> SessionConfig
pub fn with_target_sub_id(self, sub_id: impl Into<String>) -> SessionConfig
Sets the target sub ID (tag 57).
1..=MAX_ID_LEN bytes of printable ASCII except =. Checked by
SessionConfig::validate, not here.
Sourcepub fn with_logout_timeout(self, timeout: Duration) -> SessionConfig
pub fn with_logout_timeout(self, timeout: Duration) -> SessionConfig
Sets the logout timeout.
Sourcepub fn with_sending_time_tolerance(self, tolerance: Duration) -> SessionConfig
pub fn with_sending_time_tolerance(self, tolerance: Duration) -> SessionConfig
Sets the tolerance applied to an inbound SendingTime (52).
Duration::ZERO disables SendingTime validation. See
SessionConfig::sending_time_tolerance for the default and its
rationale.
Sourcepub fn with_resend_timeout(self, timeout: Duration) -> SessionConfig
pub fn with_resend_timeout(self, timeout: Duration) -> SessionConfig
Sets how long an outstanding ResendRequest (2) may make no progress
before it is retried.
Sourcepub const fn with_max_resend_requests(self, attempts: u32) -> SessionConfig
pub const fn with_max_resend_requests(self, attempts: u32) -> SessionConfig
Sets how many ResendRequest (2) messages may be sent for one gap,
counting the first. A value of 0 is read as 1.
Sourcepub const fn heartbeat_interval_secs(&self) -> u64
pub const fn heartbeat_interval_secs(&self) -> u64
Returns the heartbeat interval as the whole seconds that go into
HeartBtInt (108).
Exact for any configuration that passed SessionConfig::validate,
which is what rules out a fractional interval; on an unvalidated
configuration a sub-second interval would floor to 0, which on the wire
means “do not heartbeat”.
Sourcepub const fn resend_attempt_limit(&self) -> u32
pub const fn resend_attempt_limit(&self) -> u32
Returns how many ResendRequest (2) messages may be sent for one gap,
never less than the one that opens the recovery.
Trait Implementations§
Source§impl Clone for SessionConfig
impl Clone for SessionConfig
Source§fn clone(&self) -> SessionConfig
fn clone(&self) -> SessionConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more