Browse Source

Revert "Add an SearcherActor, wrapping Searcher & DbPool"

This reverts commit 0757f84397.
We'll attempt to use a strategy in #807
pull/813/head
Mina Galić 4 months ago
parent
commit
f945e18bf1
Signed by: igalic <me+github@igalic.co> GPG Key ID: ACFEFF7F6A123A86
2 changed files with 2 additions and 31 deletions
  1. +1
    -1
      plume-models/src/posts.rs
  2. +1
    -30
      plume-models/src/search/searcher.rs

+ 1
- 1
plume-models/src/posts.rs View File

@@ -24,7 +24,7 @@ use std::collections::HashSet;

pub type LicensedArticle = CustomObject<Licensed, Article>;

#[derive(Debug, Queryable, Identifiable, Clone, AsChangeset)]
#[derive(Queryable, Identifiable, Clone, AsChangeset)]
#[changeset_options(treat_none_as_null = "true")]
pub struct Post {
pub id: i32,


+ 1
- 30
plume-models/src/search/searcher.rs View File

@@ -1,11 +1,10 @@
use crate::{
config::SearchTokenizerConfig, db_conn::DbPool, instance::Instance, posts::Post, schema::posts,
config::SearchTokenizerConfig, instance::Instance, posts::Post, schema::posts,
search::query::PlumeQuery, tags::Tag, Connection, Result,
};
use chrono::Datelike;
use diesel::{ExpressionMethods, QueryDsl, RunQueryDsl};
use itertools::Itertools;
use riker::actors::*;
use std::{cmp, fs::create_dir_all, io, path::Path, sync::Mutex};
use tantivy::{
collector::TopDocs, directory::MmapDirectory, schema::*, Index, IndexReader, IndexWriter,
@@ -255,31 +254,3 @@ impl Searcher {
self.writer.lock().unwrap().take();
}
}

#[derive(Clone, Debug)]
pub struct AddDocument(Post);

#[actor(AddDocument)]
pub struct SearcherActor {
searcher: Searcher,
db_pool: DbPool,
}

impl Actor for SearcherActor {
// we used the #[actor] attribute so SearcherActorMsg is the Msg type
type Msg = SearcherActorMsg;

fn recv(&mut self, ctx: &Context<Self::Msg>, msg: Self::Msg, sender: Sender) {
// Use the respective Receive<T> implementation
self.receive(ctx, msg, sender);
}
}

impl Receive<AddDocument> for SearcherActor {
type Msg = SearcherActorMsg;

fn receive(&mut self, _ctx: &Context<Self::Msg>, msg: AddDocument, _sender: Sender) {
let conn = self.db_pool.get().unwrap();
let _ = self.searcher.add_document(&conn, &msg.0);
}
}

Loading…
Cancel
Save