mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
Add build time parameter
This commit is contained in:
parent
feed9ebbf0
commit
425479172c
2 changed files with 8 additions and 3 deletions
|
@ -60,6 +60,7 @@ type syncTree struct {
|
||||||
onClose func(id string)
|
onClose func(id string)
|
||||||
isClosed bool
|
isClosed bool
|
||||||
isDeleted bool
|
isDeleted bool
|
||||||
|
buildTime time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
var log = logger.NewNamed("common.commonspace.synctree")
|
var log = logger.NewNamed("common.commonspace.synctree")
|
||||||
|
@ -114,6 +115,7 @@ func PutSyncTree(ctx context.Context, payload treestorage.TreeStorageCreatePaylo
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildSyncTree(ctx context.Context, peerId string, deps BuildDeps) (t SyncTree, err error) {
|
func buildSyncTree(ctx context.Context, peerId string, deps BuildDeps) (t SyncTree, err error) {
|
||||||
|
buildStart := time.Now()
|
||||||
objTree, err := deps.BuildObjectTree(deps.TreeStorage, deps.AclList)
|
objTree, err := deps.BuildObjectTree(deps.TreeStorage, deps.AclList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -126,6 +128,7 @@ func buildSyncTree(ctx context.Context, peerId string, deps BuildDeps) (t SyncTr
|
||||||
listener: deps.Listener,
|
listener: deps.Listener,
|
||||||
syncStatus: deps.SyncStatus,
|
syncStatus: deps.SyncStatus,
|
||||||
statsCollector: deps.StatsCollector,
|
statsCollector: deps.StatsCollector,
|
||||||
|
buildTime: time.Since(buildStart),
|
||||||
}
|
}
|
||||||
syncHandler := NewSyncHandler(syncTree, syncClient, deps.SpaceId)
|
syncHandler := NewSyncHandler(syncTree, syncClient, deps.SpaceId)
|
||||||
syncTree.ObjectSyncHandler = syncHandler
|
syncTree.ObjectSyncHandler = syncHandler
|
||||||
|
|
|
@ -5,19 +5,19 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type TreeStatsCollector struct {
|
type TreeStatsCollector struct {
|
||||||
trees map[string]SyncTree
|
trees map[string]*syncTree
|
||||||
mutex sync.Mutex
|
mutex sync.Mutex
|
||||||
spaceId string
|
spaceId string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTreeStatsCollector(spaceId string) *TreeStatsCollector {
|
func NewTreeStatsCollector(spaceId string) *TreeStatsCollector {
|
||||||
return &TreeStatsCollector{
|
return &TreeStatsCollector{
|
||||||
trees: make(map[string]SyncTree),
|
trees: make(map[string]*syncTree),
|
||||||
spaceId: spaceId,
|
spaceId: spaceId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TreeStatsCollector) Register(tree SyncTree) {
|
func (t *TreeStatsCollector) Register(tree *syncTree) {
|
||||||
t.mutex.Lock()
|
t.mutex.Lock()
|
||||||
defer t.mutex.Unlock()
|
defer t.mutex.Unlock()
|
||||||
t.trees[tree.Id()] = tree
|
t.trees[tree.Id()] = tree
|
||||||
|
@ -35,6 +35,7 @@ func (t *TreeStatsCollector) Collect() []TreeStats {
|
||||||
Heads: tree.Heads(),
|
Heads: tree.Heads(),
|
||||||
ObjectId: tree.Id(),
|
ObjectId: tree.Id(),
|
||||||
SpaceId: t.spaceId,
|
SpaceId: t.spaceId,
|
||||||
|
BuildTimeSecs: int(tree.buildTime.Seconds()),
|
||||||
})
|
})
|
||||||
tree.Unlock()
|
tree.Unlock()
|
||||||
}
|
}
|
||||||
|
@ -53,4 +54,5 @@ type TreeStats struct {
|
||||||
Heads []string `json:"heads"`
|
Heads []string `json:"heads"`
|
||||||
ObjectId string `json:"object_id"`
|
ObjectId string `json:"object_id"`
|
||||||
SpaceId string `json:"space_id"`
|
SpaceId string `json:"space_id"`
|
||||||
|
BuildTimeSecs int `json:"build_time"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue