🎨 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113

This commit is contained in:
Liang Ding 2023-01-24 21:50:10 +08:00
parent e8fe3a77b3
commit c5f4d3c780
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
19 changed files with 86 additions and 28 deletions

View file

@ -864,6 +864,16 @@
"xy": "%d years %s",
"max": "a long while %s"
},
"_taskAction": {
"task.repo.checkout": "Execute checkout from snapshot",
"task.database.index.full": "Execute rebuild index",
"task.database.index": "Execute database index queue",
"task.database.index.ref": "Execute database index reference",
"task.database.index.fix": "Execute database index fix",
"task.ocr.image": "Execute image OCR to extract text",
"task.history.generateDoc": "Execute GenerateDoc History",
"task.database.index.embedBlock": "Execute database index embed block"
},
"_trayMenu": {
"showWindow": "Show Window",
"hideWindow": "Hide Window",

View file

@ -864,6 +864,16 @@
"xy": "%d años %s",
"max": "mucho tiempo %s"
},
"_taskAction": {
"task.repo.checkout": "Realizar el pago desde la instantánea",
"task.database.index.full": "Ejecutar índice de reconstrucción",
"task.database.index": "Ejecutar cola de índice de base de datos",
"task.database.index.ref": "Ejecutar referencia de índice de base de datos",
"task.database.index.fix": "Realizar corrección del índice de la base de datos",
"task.ocr.image": "Ejecutar OCR de imagen para extraer texto",
"task.history.generateDoc": "Ejecutar Historial GenerateDoc",
"task.database.index.embedBlock": "Ejecutar bloque de incrustación de índice de base de datos"
},
"_trayMenu": {
"showWindow": "Mostrar ventana",
"hideWindow": "Ocultar ventana",

View file

@ -864,6 +864,16 @@
"xy": "%d ans %s",
"max": "un bon moment %s"
},
"_taskAction": {
"task.repo.checkout": "Effectuer le paiement à partir d'un instantané",
"task.database.index.full": "Exécuter l'index de reconstruction",
"task.database.index": "Exécuter la file d'attente d'index de la base de données",
"task.database.index.ref": "Exécuter la référence d'index de la base de données",
"task.database.index.fix": "Effectuer la correction de l'index de la base de données",
"task.ocr.image": "Exécute l'OCR d'image pour extraire le texte",
"task.history.generateDoc": "Exécuter l'historique de GenerateDoc",
"task.database.index.embedBlock": "Exécuter le bloc d'intégration d'index de base de données"
},
"_trayMenu": {
"showWindow": "Afficher la fenêtre principale",
"hideWindow": "Masquer la fenêtre principale",

View file

@ -864,6 +864,16 @@
"xy": "%d 年%s",
"max": "很久%s"
},
"_taskAction": {
"task.repo.checkout": "執行從快照中檢出",
"task.database.index.full": "執行重建索引",
"task.database.index": "執行數據庫索引隊列",
"task.database.index.ref": "執行數據庫索引引用",
"task.database.index.fix": "執行數據庫索引訂正",
"task.ocr.image": "執行圖片 OCR 提取文本",
"task.history.generateDoc": "執行生成文件歷史",
"task.database.index.embedBlock": "執行數據庫索引嵌入塊"
},
"_trayMenu": {
"showWindow": "顯示主窗口",
"hideWindow": "隱藏主窗口",
@ -1062,4 +1072,4 @@
"184": "由<a href=\"https://b3log.org/siyuan\" target=\"_blank\">思源筆記</a>強力驅動",
"185": "索引校驗完畢"
}
}
},

View file

@ -864,6 +864,16 @@
"xy": "%d 年%s",
"max": "很久%s"
},
"_taskAction": {
"task.repo.checkout": "执行从快照中检出",
"task.database.index.full": "执行重建索引",
"task.database.index": "执行数据库索引队列",
"task.database.index.ref": "执行数据库索引引用",
"task.database.index.fix": "执行数据库索引订正",
"task.ocr.image": "执行图片 OCR 提取文本",
"task.history.generateDoc": "执行生成文件历史",
"task.database.index.embedBlock": "执行数据库索引嵌入块"
},
"_trayMenu": {
"showWindow": "显示主窗口",
"hideWindow": "隐藏主窗口",

View file

@ -271,6 +271,7 @@ func setAppearance(c *gin.Context) {
model.Conf.Appearance = appearance
model.Conf.Lang = appearance.Lang
util.Lang = model.Conf.Lang
model.Conf.Save()
model.InitAppearance()

View file

@ -18,6 +18,7 @@ package mobile
import (
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"os"
"path/filepath"
"strings"
@ -27,7 +28,6 @@ import (
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/server"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
_ "golang.org/x/mobile/bind"

View file

@ -20,6 +20,7 @@ import (
"bytes"
"errors"
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"io/ioutil"
"os"
"path"
@ -39,7 +40,6 @@ import (
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/conf"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)

View file

@ -105,7 +105,7 @@ func InitConf() {
if userLang, err := locale.Detect(); nil == err {
var supportLangs []language.Tag
for lang := range langs {
for lang := range util.Langs {
if tag, err := language.Parse(lang); nil == err {
supportLangs = append(supportLangs, tag)
} else {
@ -125,6 +125,7 @@ func InitConf() {
Conf.Lang = util.Lang
}
}
util.Lang = Conf.Lang
}
Conf.Langs = loadLangs()
@ -140,6 +141,7 @@ func InitConf() {
}
if !langOK {
Conf.Lang = "en_US"
util.Lang = Conf.Lang
}
Conf.Appearance.Lang = Conf.Lang
if nil == Conf.UILayout {
@ -321,9 +323,6 @@ func InitConf() {
util.SetNetworkProxy(Conf.System.NetworkProxy.String())
}
var langs = map[string]map[int]string{}
var timeLangs = map[string]map[string]interface{}{}
func initLang() {
p := filepath.Join(util.WorkingDir, "appearance", "langs")
dir, err := os.Open(p)
@ -363,14 +362,15 @@ func initLang() {
}
kernelMap[-1] = label
name := langName[:strings.LastIndex(langName, ".")]
langs[name] = kernelMap
util.Langs[name] = kernelMap
timeLangs[name] = langMap["_time"].(map[string]interface{})
util.TimeLangs[name] = langMap["_time"].(map[string]interface{})
util.TaskActionLangs[name] = langMap["_taskAction"].(map[string]interface{})
}
}
func loadLangs() (ret []*conf.Lang) {
for name, langMap := range langs {
for name, langMap := range util.Langs {
lang := &conf.Lang{Label: langMap[-1], Name: name}
ret = append(ret, lang)
}
@ -567,11 +567,11 @@ func (conf *AppConf) GetClosedBoxes() (ret []*Box) {
}
func (conf *AppConf) Language(num int) (ret string) {
ret = langs[conf.Lang][num]
ret = util.Langs[conf.Lang][num]
if "" != ret {
return
}
ret = langs["en_US"][num]
ret = util.Langs["en_US"][num]
return
}

View file

@ -19,6 +19,7 @@ package model
import (
"errors"
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"math"
"os"
"path"
@ -43,7 +44,6 @@ import (
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/search"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)
@ -97,7 +97,7 @@ func (box *Box) docFromFileInfo(fileInfo *FileInfo, ial map[string]string) (ret
}
func HumanizeTime(then time.Time) string {
labels := timeLangs[Conf.Lang]
labels := util.TimeLangs[Conf.Lang]
defaultMagnitudes := []humanize.RelTimeMagnitude{
{time.Second, labels["now"].(string), time.Second},

View file

@ -19,6 +19,7 @@ package model
import (
"encoding/json"
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"io/fs"
"math"
"os"
@ -38,7 +39,6 @@ import (
"github.com/siyuan-note/siyuan/kernel/conf"
"github.com/siyuan-note/siyuan/kernel/search"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)

View file

@ -18,6 +18,7 @@ package model
import (
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"strings"
"time"
@ -29,7 +30,6 @@ import (
"github.com/siyuan-note/siyuan/kernel/cache"
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)

View file

@ -1,6 +1,7 @@
package model
import (
"github.com/siyuan-note/siyuan/kernel/task"
"io"
"os"
"path/filepath"
@ -15,7 +16,6 @@ import (
"github.com/panjf2000/ants/v2"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/cache"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/util"
)

View file

@ -23,6 +23,7 @@ import (
"encoding/base64"
"errors"
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"math"
"net/http"
"os"
@ -49,7 +50,6 @@ import (
"github.com/siyuan-note/siyuan/kernel/cache"
"github.com/siyuan-note/siyuan/kernel/conf"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
"github.com/studio-b12/gowebdav"

View file

@ -20,6 +20,7 @@ import (
"bytes"
"errors"
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"path"
"regexp"
"sort"
@ -38,7 +39,6 @@ import (
"github.com/siyuan-note/siyuan/kernel/conf"
"github.com/siyuan-note/siyuan/kernel/search"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
"github.com/xrash/smetrics"

View file

@ -32,7 +32,6 @@ import (
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/conf"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)
@ -92,12 +91,8 @@ func BootSyncData() {
}
func SyncData(boot, exit, byHand bool) {
if !checkSync(boot, exit, byHand) {
return
}
util.BroadcastByType("main", "syncing", 0, Conf.Language(81), nil)
task.PrependTask(task.CloudSync, syncData, boot, exit, byHand)
syncData(boot, exit, byHand)
}
func syncData(boot, exit, byHand bool) {

View file

@ -20,6 +20,7 @@ import (
"bytes"
"errors"
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"os"
"path"
"path/filepath"
@ -38,7 +39,6 @@ import (
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/cache"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)

View file

@ -98,7 +98,6 @@ func newTask(action string, handler interface{}, args ...interface{}) *Task {
}
const (
CloudSync = "task.cloud.sync" // 数据同步
RepoCheckout = "task.repo.checkout" // 从快照中检出
DatabaseIndexFull = "task.database.index.full" // 重建索引
DatabaseIndex = "task.database.index" // 数据库索引队列
@ -120,8 +119,15 @@ func StatusLoop() {
continue
}
actionLangs := util.TaskActionLangs[util.Lang]
action := task.Action
if nil != actionLangs {
if label := actionLangs[task.Action]; nil != label {
action = label.(string)
}
}
item := map[string]interface{}{
"action": task.Action,
"action": action,
}
items = append(items, item)
}

View file

@ -104,3 +104,9 @@ const (
// SQLFlushInterval 为数据库事务队列写入间隔。
SQLFlushInterval = 3000 * time.Millisecond
)
var (
Langs = map[string]map[int]string{}
TimeLangs = map[string]map[string]interface{}{}
TaskActionLangs = map[string]map[string]interface{}{}
)