v0.6.0

資料配置

最後更新


KuraDB 在磁碟上存放檔案的位置,以及每個資料庫 SQLite 資料表的結構。

目錄結構


  1. ~/.config/kuradb/
  2. ├── db.json registry: [{"db": "<name>", "createAt": "<RFC 3339 UTC>"}]
  3. ├── config.json port and remote settings
  4. ├── endpoint daemon URL, present while the HTTP server runs
  5. ├── runtime.uid {"uid", "pid", "started_at"} of the running daemon
  6. ├── daemon.log daemon output, appended
  7. └── <name>/
  8. ├── inbox/ watched folder; drop files here
  9. ├── data.db SQLite database (WAL mode, plus -wal and -shm files)
  10. └── record.json watcher snapshot of the inbox tree
  11. ~/Kura_<name> symlink to ~/.config/kuradb/<name>/inbox

~/Kura_<name> 不存在或指向他處時,每次 daemon 啟動都會重建;若該路徑上是非 symlink 的檔案,該資料庫會記錄警告後略過。

file_data 資料表


每個資料庫只有一張資料表,由 internal/database/schema/file_data.sql 建立:
欄位型別意義
idINTEGER PRIMARY KEY資料列 id;搜尋的第二排序鍵
sourceTEXT NOT NULL檔案在 inbox 內的絕對路徑
chunkINTEGER NOT NULL檔案內從 1 起算的 chunk 編號
totalINTEGER NOT NULL寫入當下該檔的 chunk 總數
contentTEXT NOT NULLchunk 內容
dismissBOOLEAN NOT NULL DEFAULT FALSEchunk 被取代或檔案被移除後為 TRUE
created_at、updated_atTIMESTAMP插入與更新時設為 CURRENT_TIMESTAMP

(source, chunk) 為唯一鍵,idx_file_data_source 為 source 建立索引。

SQLite 連線


每個 data.db 透過 go-sqlkit 開啟,一條寫入連線加上 8 條的讀取連線池。兩者都使用 WAL journal 與 50 秒 busy timeout;讀取連線池以唯讀模式開啟檔案。因此 kura mcp 程序可在 daemon 寫入時同時讀取。

相關頁面


EN