Skip to content

Commit 26cfccb

Browse files
committed
chore: improvements
1 parent 3664dd1 commit 26cfccb

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

crates/rostra-client/src/task/followee_head_checker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl FolloweeHeadChecker {
4040
}
4141

4242
/// Run the thread
43-
#[instrument(skip(self), ret)]
43+
#[instrument(name = "followee-head-checker", skip(self), ret)]
4444
pub async fn run(self) {
4545
let mut check_for_updates_rx = self.check_for_updates_rx.clone();
4646
let mut followee_updated = self.followee_updated.clone();

crates/rostra-client/src/task/missing_event_content_fetcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl MissingEventContentFetcher {
3030
}
3131

3232
/// Run the thread
33-
#[instrument(skip(self), ret)]
33+
#[instrument(name = "missing-event-content-fetcher", skip(self), ret)]
3434
pub async fn run(self) {
3535
let mut interval = tokio::time::interval(if is_rostra_dev_mode_set() {
3636
Duration::from_secs(10)

crates/rostra-client/src/task/missing_event_fetcher.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,29 @@ impl MissingEventFetcher {
3030
}
3131

3232
/// Run the thread
33-
#[instrument(skip(self), ret)]
33+
#[instrument(name = "missing-event-fetcher", skip(self), ret)]
3434
pub async fn run(self) {
35+
let mut initial_followers = {
36+
let Ok(db) = self.client.db() else {
37+
return;
38+
};
39+
db
40+
}
41+
.get_followees(self.self_id)
42+
.await;
3543
let mut ids_with_missing_events_rx = self.ids_with_missing_events_rx.clone();
3644

3745
loop {
38-
let author_id = match ids_with_missing_events_rx.recv().await {
39-
Ok(id) => id,
40-
Err(dedup_chan::RecvError::Closed) => break,
41-
Err(dedup_chan::RecvError::Lagging) => {
42-
warn!(target: LOG_TARGET, "Missing event fetcher missed some notifications");
43-
continue;
46+
let author_id = if let Some(initial_follower_id) = initial_followers.pop() {
47+
initial_follower_id.0
48+
} else {
49+
match ids_with_missing_events_rx.recv().await {
50+
Ok(id) => id,
51+
Err(dedup_chan::RecvError::Closed) => break,
52+
Err(dedup_chan::RecvError::Lagging) => {
53+
warn!(target: LOG_TARGET, "Missing event fetcher missed some notifications");
54+
continue;
55+
}
4456
}
4557
};
4658
trace!(target: LOG_TARGET, "Woke up");
@@ -52,6 +64,7 @@ impl MissingEventFetcher {
5264
let followers = db.get_followers(author_id).await;
5365
let missing_events = db.get_missing_events_for_id(author_id).await;
5466

67+
debug!(target: LOG_TARGET, len=missing_events.len(), id=%author_id, "Missing events for id");
5568
if missing_events.is_empty() {
5669
continue;
5770
}

0 commit comments

Comments
 (0)