Module pingable

Source
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

  • Pingable Trait: 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 the check_quit_increment_counter_ping_database! macro.

  • Implementations: The module provides impl Pingable blocks for various SqlInterface... structs (SqlInterfaceData, SqlInterfaceBalling, etc.). Each implementation calls a common SqlInterface::ping_database function, 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 conn field which is a mutable database connection that can be passed to SqlInterface::ping_database.

Traits§

Pingable
Represents a component that can be “pinged” to keep a connection alive.