added documentation for broadcasting docker container
This commit is contained in:
@@ -152,6 +152,41 @@ async fn get_server_id_by_ip(
|
||||
}
|
||||
}
|
||||
|
||||
/// Broadcasts Docker container information to the monitoring server for service discovery.
|
||||
///
|
||||
/// This function sends the current Docker container configuration to the server
|
||||
/// to register available containers and enable service monitoring. It will
|
||||
/// continuously retry until successful, making it suitable for initial
|
||||
/// registration scenarios.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `base_url` - The base URL of the monitoring server API (e.g., "https://monitoring.example.com")
|
||||
/// * `server_id` - The ID of the server to associate the containers with
|
||||
/// * `container_dto` - Mutable reference to Docker container information for broadcast
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Ok(())` - When container information is successfully broadcasted to the server
|
||||
/// * `Err(Box<dyn Error + Send + Sync>)` - If an unrecoverable error occurs (though the function typically retries on transient failures)
|
||||
///
|
||||
/// # Behavior
|
||||
///
|
||||
/// This function operates in a retry loop with the following characteristics:
|
||||
///
|
||||
/// - **Retry Logic**: Attempts broadcast every 10 seconds until successful
|
||||
/// - **Mutation**: Modifies the `container_dto` to set the `server_id` before sending
|
||||
/// - **TLS**: Accepts invalid TLS certificates for development environments
|
||||
/// - **Logging**: Provides detailed console output about broadcast attempts and results
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// This function may return an error in the following cases:
|
||||
///
|
||||
/// * **HTTP Client Creation**: Failed to create HTTP client with TLS configuration
|
||||
/// * **Network Issues**: Persistent connection failures to the backend server
|
||||
/// * **Server Errors**: Backend returns non-success HTTP status codes repeatedly
|
||||
/// * **JSON Serialization**: Cannot serialize container data (should be rare with proper DTOs)
|
||||
pub async fn broadcast_docker_containers(
|
||||
base_url: &str,
|
||||
server_id: u16,
|
||||
|
||||
Reference in New Issue
Block a user