Mercurial Hosting > disearch
diff src/lib/Db.luan @ 3:43814e9f5802
add config
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 21 Oct 2023 22:52:41 -0600 |
parents | |
children | af2b95854072 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib/Db.luan Sat Oct 21 22:52:41 2023 -0600 @@ -0,0 +1,29 @@ +local Luan = require "luan:Luan.luan" +local error = Luan.error +local new_error = Luan.new_error or error() +local Lucene = require "luan:lucene/Lucene.luan" +local Io = require "luan:Io.luan" +local uri = Io.uri or error() +local Http = require "luan:http/Http.luan" +local Thread = require "luan:Thread.luan" +local Time = require "luan:Time.luan" +local Logging = require "luan:logging/Logging.luan" +local logger = Logging.logger "Db" + + +local dir = uri("site:/private/local/lucene") + +local Db = Lucene.index( dir, { + log_dir = uri("site:/private/local/lucene_log") + name = "lucene" +} ) + +function Db.not_in_transaction() + logger.error(new_error("not in transaction")) +end + +if Http.is_serving then + Thread.schedule( Db.check, { delay=0, repeating_delay=Time.period{hours=1} } ) +end + +return Db