Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Better self-service commands for DHT providing #815

Merged
merged 7 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ The following emojis are used to highlight certain changes:
### Security


## [v0.27.3]

### Added

- `provider` Added LastRun and NextRun stats to the Reprovider. [#815](https://github.com/ipfs/boxo/pull/815)
guillaumemichel marked this conversation as resolved.
Show resolved Hide resolved


## [v0.27.2]

### Fixed
Expand Down
5 changes: 5 additions & 0 deletions provider/reprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
statLk sync.Mutex
totalProvides, lastReprovideBatchSize uint64
avgProvideDuration, lastReprovideDuration time.Duration
lastRun time.Time

throughputCallback ThroughputCallback
// throughputProvideCurrentCount counts how many provides has been done since the last call to throughputCallback
Expand Down Expand Up @@ -357,6 +358,7 @@
s.statLk.Lock()
s.avgProvideDuration = (totalProvideTime + dur) / (time.Duration(s.totalProvides) + time.Duration(len(keys)))
s.totalProvides += uint64(len(keys))
s.lastRun = time.Now()

log.Debugf("finished providing of %d keys. It took %v with an average of %v per provide", len(keys), dur, recentAvgProvideDuration)

Expand Down Expand Up @@ -539,6 +541,7 @@
type ReproviderStats struct {
TotalProvides, LastReprovideBatchSize uint64
AvgProvideDuration, LastReprovideDuration time.Duration
LastRun, NextRun time.Time
}

// Stat returns various stats about this provider system
Expand All @@ -550,6 +553,8 @@
LastReprovideBatchSize: s.lastReprovideBatchSize,
AvgProvideDuration: s.avgProvideDuration,
LastReprovideDuration: s.lastReprovideDuration,
LastRun: s.lastRun,
NextRun: s.lastRun.Add(DefaultReproviderInterval),

Check warning on line 557 in provider/reprovider.go

View check run for this annotation

Codecov / codecov/patch

provider/reprovider.go#L556-L557

Added lines #L556 - L557 were not covered by tests
}, nil
}

Expand Down