pub fn watch_for_reminders(mut pool: ConnectionPool) -> ! {
    loop {
        thread::sleep(time::Duration::from_secs(60));

        // Get expired reminders.
        let reminders = match pool.get_expired_reminders() {
            Ok(rows) => rows,
            Err(why) => {
                error!("Failed to get reminders: {:?}", why);
                continue;
            }
        };

        // Delete the reminder no matter if the reminder was sent sucessfully
        // or not to avoid retrying to message deleted accounts forever.
        for reminder in reminders.iter() {
            if let Err(why) = pool.delete_reminder(reminder.id) {
                warn!("Failed to delete reminder: {}", why);
            };
        }

        // Send all reminders.
        for reminder in reminders.into_iter() {
            if let Err(why) = dm_with_message(reminder) {
                error!("Error while DM'ing: {}", why);
            }
        }
    }
}
/// Infinite loop that checks the database periodically for expired reminders.
Infinite loop that checks the database periodically for expired reminders.
Infinite loop that checks the database periodically for expired reminders .
pub fn watch_for_reminders(mut pool: ConnectionPool) -> ! {
    loop {
        thread::sleep(time::Duration::from_secs(60));
        // Get expired reminders.
        let reminders = match pool.get_expired_reminders() {
            Ok(rows) => rows,
            Err(why) => {
                error!("Failed to get reminders: {:?}", why);
                continue;
            }
        };
        // Delete the reminder no matter if the reminder was sent sucessfully
        // or not to avoid retrying to message deleted accounts forever.
        for reminder in reminders.iter() {
            if let Err(why) = pool.delete_reminder(reminder.id) {
                warn!("Failed to delete reminder: {}", why);
            };
        }
        // Send all reminders.
        for reminder in reminders.into_iter() {
            if let Err(why) = dm_with_message(reminder) {
                error!("Error while DM'ing: {}", why);
            }
        }
    }
}
pub fn watch_for_reminders ( mut pool : ConnectionPool ) -> ! { loop { thread :: sleep ( time :: Duration :: from_secs ( 60 ) ) ; // Get expired reminders. let reminders = match pool . get_expired_reminders ( ) { Ok ( rows ) => rows , Err ( why ) => { error ! ( " " why ) ; continue ; } } ; // Delete the reminder no matter if the reminder was sent sucessfully // or not to avoid retrying to message deleted accounts forever. for reminder in reminders . iter ( ) { if let Err ( why ) = pool . delete_reminder ( reminder . id ) { warn ! ( " " why ) ; } ; } // Send all reminders. for reminder in reminders . into_iter ( ) { if let Err ( why ) = dm_with_message ( reminder ) { error ! ( " " why ) ; } } } }
Infinite loop that checks the database periodically for expired reminders.
Infinite loop that checks the database periodically for expired reminders .
pool
ConnectionPool