Skip to content

Commit b456679

Browse files
committed
godoc
1 parent 379787e commit b456679

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

internal/verifier/worker_tracker.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,26 @@ import (
66
"github.com/10gen/migration-verifier/msync"
77
)
88

9+
// WorkerTracker holds certain data points about each worker thread
10+
// in a check generation. It is thread-safe.
911
type WorkerTracker struct {
1012
guard *msync.DataGuard[WorkerStatusMap]
1113
}
1214

15+
// WorkerStatusMap represents the status of each worker,
16+
// indexed by worker number (which start at 0).
1317
type WorkerStatusMap = map[int]WorkerStatus
1418

19+
// WorkerStatus details the work that an individual worker thread
20+
// is doing.
1521
type WorkerStatus struct {
1622
TaskID any
1723
TaskType verificationTaskType
1824
Namespace string
1925
StartTime time.Time
2026
}
2127

28+
// NewWorkerTracker creates and returns a WorkerTracker.
2229
func NewWorkerTracker(workersCount int) *WorkerTracker {
2330
wsmap := WorkerStatusMap{}
2431
for i := 0; i < workersCount; i++ {
@@ -29,6 +36,7 @@ func NewWorkerTracker(workersCount int) *WorkerTracker {
2936
}
3037
}
3138

39+
// Set updates the worker’s state in the WorkerTracker.
3240
func (wt *WorkerTracker) Set(workerNum int, task VerificationTask) {
3341
wt.guard.Store(func(m WorkerStatusMap) WorkerStatusMap {
3442
m[workerNum] = WorkerStatus{
@@ -42,6 +50,7 @@ func (wt *WorkerTracker) Set(workerNum int, task VerificationTask) {
4250
})
4351
}
4452

53+
// Unset tells the WorkerTracker that the worker is now inactive.
4554
func (wt *WorkerTracker) Unset(workerNum int) {
4655
wt.guard.Store(func(m WorkerStatusMap) WorkerStatusMap {
4756
m[workerNum] = WorkerStatus{}
@@ -50,6 +59,8 @@ func (wt *WorkerTracker) Unset(workerNum int) {
5059
})
5160
}
5261

62+
// Load duplicates and returns the WorkerTracker’s internal
63+
// state map.
5364
func (wt *WorkerTracker) Load() WorkerStatusMap {
5465
var wtmap WorkerStatusMap
5566
wt.guard.Load(func(m map[int]WorkerStatus) {

0 commit comments

Comments
 (0)