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)
|
||||
isClosed bool
|
||||
isDeleted bool
|
||||
buildTime time.Duration
|
||||
}
|
||||
|
||||
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) {
|
||||
buildStart := time.Now()
|
||||
objTree, err := deps.BuildObjectTree(deps.TreeStorage, deps.AclList)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -126,6 +128,7 @@ func buildSyncTree(ctx context.Context, peerId string, deps BuildDeps) (t SyncTr
|
|||
listener: deps.Listener,
|
||||
syncStatus: deps.SyncStatus,
|
||||
statsCollector: deps.StatsCollector,
|
||||
buildTime: time.Since(buildStart),
|
||||
}
|
||||
syncHandler := NewSyncHandler(syncTree, syncClient, deps.SpaceId)
|
||||
syncTree.ObjectSyncHandler = syncHandler
|
||||
|
|
|
@ -5,19 +5,19 @@ import (
|
|||
)
|
||||
|
||||
type TreeStatsCollector struct {
|
||||
trees map[string]SyncTree
|
||||
trees map[string]*syncTree
|
||||
mutex sync.Mutex
|
||||
spaceId string
|
||||
}
|
||||
|
||||
func NewTreeStatsCollector(spaceId string) *TreeStatsCollector {
|
||||
return &TreeStatsCollector{
|
||||
trees: make(map[string]SyncTree),
|
||||
trees: make(map[string]*syncTree),
|
||||
spaceId: spaceId,
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TreeStatsCollector) Register(tree SyncTree) {
|
||||
func (t *TreeStatsCollector) Register(tree *syncTree) {
|
||||
t.mutex.Lock()
|
||||
defer t.mutex.Unlock()
|
||||
t.trees[tree.Id()] = tree
|
||||
|
@ -35,6 +35,7 @@ func (t *TreeStatsCollector) Collect() []TreeStats {
|
|||
Heads: tree.Heads(),
|
||||
ObjectId: tree.Id(),
|
||||
SpaceId: t.spaceId,
|
||||
BuildTimeSecs: int(tree.buildTime.Seconds()),
|
||||
})
|
||||
tree.Unlock()
|
||||
}
|
||||
|
@ -53,4 +54,5 @@ type TreeStats struct {
|
|||
Heads []string `json:"heads"`
|
||||
ObjectId string `json:"object_id"`
|
||||
SpaceId string `json:"space_id"`
|
||||
BuildTimeSecs int `json:"build_time"`
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue