mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-29 08:21:47 +00:00
tasks: do not return errors or it may skip subsequent tasks
This commit is contained in:
parent
6a87b9c98f
commit
87347bb307
@ -1,4 +1,4 @@
|
|||||||
use crate::error::{Error, ErrorKind};
|
use crate::error::ErrorKind;
|
||||||
use crate::RunState;
|
use crate::RunState;
|
||||||
use crate::GLOBALS;
|
use crate::GLOBALS;
|
||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
@ -32,21 +32,17 @@ pub(crate) fn start_background_tasks() {
|
|||||||
if !GLOBALS.storage.read_setting_offline()
|
if !GLOBALS.storage.read_setting_offline()
|
||||||
&& *read_runstate.borrow() == RunState::Online
|
&& *read_runstate.borrow() == RunState::Online
|
||||||
{
|
{
|
||||||
if let Err(e) = do_online_tasks(tick).await {
|
do_online_tasks(tick).await;
|
||||||
tracing::error!("{}", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = do_general_tasks(tick).await {
|
do_general_tasks(tick).await;
|
||||||
tracing::error!("{}", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tracing::info!("Stopping general background tasks");
|
tracing::info!("Stopping general background tasks");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn do_online_tasks(tick: usize) -> Result<(), Error> {
|
async fn do_online_tasks(tick: usize) {
|
||||||
// Do fetcher tasks (every 2 seconds)
|
// Do fetcher tasks (every 2 seconds)
|
||||||
if tick % 2 == 0 {
|
if tick % 2 == 0 {
|
||||||
GLOBALS.fetcher.process_queue().await;
|
GLOBALS.fetcher.process_queue().await;
|
||||||
@ -68,11 +64,9 @@ async fn do_online_tasks(tick: usize) -> Result<(), Error> {
|
|||||||
if tick % 2 == 0 {
|
if tick % 2 == 0 {
|
||||||
GLOBALS.people.maybe_fetch_metadata().await;
|
GLOBALS.people.maybe_fetch_metadata().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn do_general_tasks(tick: usize) -> Result<(), Error> {
|
async fn do_general_tasks(tick: usize) {
|
||||||
// Update GLOBALS.unread_dms count (every 3 seconds)
|
// Update GLOBALS.unread_dms count (every 3 seconds)
|
||||||
if tick % 3 == 0 {
|
if tick % 3 == 0 {
|
||||||
// Update unread dm channels, whether or not we are in that feed
|
// Update unread dm channels, whether or not we are in that feed
|
||||||
@ -81,6 +75,4 @@ async fn do_general_tasks(tick: usize) -> Result<(), Error> {
|
|||||||
GLOBALS.unread_dms.store(unread, Ordering::Relaxed);
|
GLOBALS.unread_dms.store(unread, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user