SearchActor waits for transaction commit

This commit is contained in:
Kitaiti Makoto 2021-01-11 12:05:46 +09:00
parent 47e67d9b64
commit 2483303138
1 changed files with 5 additions and 0 deletions

View File

@ -2,6 +2,8 @@ use super::Searcher;
use crate::{db_conn::DbPool, posts::PostEvent, ACTOR_SYS, POST_CHAN};
use riker::actors::{Actor, ActorFactoryArgs, ActorRefFactory, Context, Sender, Subscribe, Tell};
use std::sync::Arc;
use std::thread::sleep;
use std::time::Duration;
use tracing::error;
pub struct SearchActor {
@ -33,6 +35,9 @@ impl Actor for SearchActor {
fn recv(&mut self, _ctx: &Context<Self::Msg>, msg: Self::Msg, _sender: Sender) {
use PostEvent::*;
// Wait for transaction commited
sleep(Duration::from_millis(500));
match msg {
PostPublished(post) => {
let conn = self.conn.get();