Expand description
Represents a component that can be “pinged” to keep a connection alive. Defines a contract for components that permanently use a database connection.
This module introduces the Pingable trait, which provides a generic interface
for sending a lightweight “ping” to a database to prevent it from timing out
due to inactivity.
§Key Components
-
PingableTrait: A simple trait with a single method,ping(). It abstracts the action of performing a keep-alive check. By using a trait, generic functions and macros can operate on any database interface that implements this behavior without needing to know its concrete type. This is heavily used by thecheck_quit_increment_counter_ping_database!macro. -
Implementations: The module provides
impl Pingableblocks for variousSqlInterface...structs (SqlInterfaceData,SqlInterfaceBalling, etc.). Each implementation calls a commonSqlInterface::ping_databasefunction, ensuring consistent behavior across the application.
§Design and Purpose
The primary goal is to create a uniform, “fire-and-forget” keep-alive mechanism. Long-running threads that interact with the database only intermittently can use this trait to ensure their connection remains active.
The ping method is designed to be non-disruptive; it logs any errors internally
but does not propagate them. This prevents keep-alive failures from crashing
a main control loop.
Macros§
- impl_
pingable 🔒 - This macro assumes that each struct provided has a
connfield which is a mutable database connection that can be passed toSqlInterface::ping_database.
Traits§
- Pingable
- Represents a component that can be “pinged” to keep a connection alive.