pub struct ApplicationHeartbeatConfig {
pub interval: Duration,
pub payload: Message,
pub send_timeout: Duration,
pub response_timeout: Option<Duration>,
pub max_missed_responses: u32,
pub matcher: Option<ApplicationHeartbeatMatcher>,
pub receive_options: ReceiveOptions,
pub failure_action: ApplicationHeartbeatFailureAction,
}Expand description
Configuration for a fixed-interval application heartbeat loop.
Fields§
§interval: DurationDelay between heartbeat attempts. The first heartbeat is sent after this delay.
payload: MessageText or binary payload sent on every heartbeat attempt.
send_timeout: DurationMaximum time allowed for queue admission and the local write.
response_timeout: Option<Duration>How long to wait for a matching response after a successful write.
None disables response matching and timeout accounting.
max_missed_responses: u32Number of consecutive missed responses tolerated before Stop takes effect.
matcher: Option<ApplicationHeartbeatMatcher>Optional application response matcher. When absent, writes are observed only.
receive_options: ReceiveOptionsReceive queue used exclusively by the heartbeat loop when a matcher is set.
The default is ReceiveOverflow::DropOldest so unrelated business
traffic cannot close the session; selecting Disconnect makes queue
overflow a heartbeat receiver failure by design.
failure_action: ApplicationHeartbeatFailureActionFailure handling policy for writes, receiver failures, and response timeouts.
Implementations§
Source§impl ApplicationHeartbeatConfig
impl ApplicationHeartbeatConfig
Sourcepub fn new(interval: Duration, payload: impl Into<Message>) -> Self
pub fn new(interval: Duration, payload: impl Into<Message>) -> Self
Creates a fixed-interval heartbeat configuration with no response matching.
Sourcepub fn with_send_timeout(self, timeout: Duration) -> Self
pub fn with_send_timeout(self, timeout: Duration) -> Self
Sets the timeout used for queue admission and local WebSocket writing.
Sourcepub fn with_response_matcher(
self,
timeout: Duration,
matcher: impl Fn(&IncomingMessage) -> bool + Send + Sync + 'static,
) -> Self
pub fn with_response_matcher( self, timeout: Duration, matcher: impl Fn(&IncomingMessage) -> bool + Send + Sync + 'static, ) -> Self
Enables response matching with the supplied timeout and matcher.
Sourcepub fn with_max_missed_responses(self, max_missed_responses: u32) -> Self
pub fn with_max_missed_responses(self, max_missed_responses: u32) -> Self
Sets the maximum number of consecutive response timeouts.
Sourcepub fn with_receive_options(self, receive_options: ReceiveOptions) -> Self
pub fn with_receive_options(self, receive_options: ReceiveOptions) -> Self
Sets the receive queue options used by the heartbeat loop.
Sourcepub fn with_failure_action(
self,
failure_action: ApplicationHeartbeatFailureAction,
) -> Self
pub fn with_failure_action( self, failure_action: ApplicationHeartbeatFailureAction, ) -> Self
Sets whether failures stop or leave the loop running.