mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-11 18:20:33 +09:00
GO-5366 Add debug stat (#2277)
This commit is contained in:
parent
f8b723b91e
commit
f0d3cde2b0
2 changed files with 36 additions and 0 deletions
|
@ -25,6 +25,7 @@ import (
|
|||
"unicode"
|
||||
|
||||
"github.com/anyproto/any-sync/app"
|
||||
"github.com/anyproto/any-sync/app/debugstat"
|
||||
tantivy "github.com/anyproto/tantivy-go"
|
||||
"github.com/valyala/fastjson"
|
||||
|
||||
|
@ -102,6 +103,19 @@ type ftSearch struct {
|
|||
lang tantivy.Language
|
||||
}
|
||||
|
||||
func (f *ftSearch) ProvideStat() any {
|
||||
count, _ := f.DocCount()
|
||||
return count
|
||||
}
|
||||
|
||||
func (f *ftSearch) StatId() string {
|
||||
return "doc_count"
|
||||
}
|
||||
|
||||
func (f *ftSearch) StatType() string {
|
||||
return CName
|
||||
}
|
||||
|
||||
func TantivyNew() FTSearch {
|
||||
return new(ftSearch)
|
||||
}
|
||||
|
@ -138,6 +152,10 @@ func (f *ftSearch) DeleteObject(objectId string) error {
|
|||
|
||||
func (f *ftSearch) Init(a *app.App) error {
|
||||
repoPath := app.MustComponent[wallet.Wallet](a).RepoPath()
|
||||
statService, _ := app.GetComponent[debugstat.StatService](a)
|
||||
if statService != nil {
|
||||
statService.AddProvider(f)
|
||||
}
|
||||
f.lang = validateLanguage(app.MustComponent[wallet.Wallet](a).FtsPrimaryLang())
|
||||
f.rootPath = filepath.Join(repoPath, ftsDir2)
|
||||
f.blevePath = filepath.Join(repoPath, ftsDir)
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
anystore "github.com/anyproto/any-store"
|
||||
"github.com/anyproto/any-store/anyenc"
|
||||
"github.com/anyproto/any-sync/app"
|
||||
"github.com/anyproto/any-sync/app/debugstat"
|
||||
"github.com/anyproto/any-sync/coordinator/coordinatorproto"
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
|
@ -124,6 +125,19 @@ type dsObjectStore struct {
|
|||
componentCtxCancel context.CancelFunc
|
||||
}
|
||||
|
||||
func (s *dsObjectStore) ProvideStat() any {
|
||||
count, _ := s.ListIdsCrossSpace()
|
||||
return len(count)
|
||||
}
|
||||
|
||||
func (s *dsObjectStore) StatId() string {
|
||||
return "ds_count"
|
||||
}
|
||||
|
||||
func (s *dsObjectStore) StatType() string {
|
||||
return CName
|
||||
}
|
||||
|
||||
func (s *dsObjectStore) IterateSpaceIndex(f func(store spaceindex.Store) error) error {
|
||||
s.Lock()
|
||||
spaceIndexes := make([]spaceindex.Store, 0, len(s.spaceIndexes))
|
||||
|
@ -169,6 +183,10 @@ func (s *dsObjectStore) Init(a *app.App) (err error) {
|
|||
s.setDefaultConfig()
|
||||
s.oldStore = app.MustComponent[oldstore.Service](a)
|
||||
s.techSpaceIdProvider = app.MustComponent[TechSpaceIdProvider](a)
|
||||
statService, _ := app.GetComponent[debugstat.StatService](a)
|
||||
if statService != nil {
|
||||
statService.AddProvider(s)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue