Add download speed limit support (#3408)

This commit is contained in:
LHHDZ
2022-08-05 16:16:42 +08:00
committed by GitHub
parent b278bb24d3
commit 84ec68e11a
5 changed files with 12 additions and 1 deletions

View File

@@ -68,6 +68,7 @@ type FilerOption struct {
SaveToFilerLimit int64
ConcurrentUploadLimit int64
ShowUIDirectoryDelete bool
DownloadMaxBytesPs int64
}
type FilerServer struct {

View File

@@ -238,7 +238,7 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
}
}
err = filer.StreamContent(fs.filer.MasterClient, writer, chunks, offset, size)
err = filer.StreamContentWithThrottler(fs.filer.MasterClient, writer, chunks, offset, size, fs.option.DownloadMaxBytesPs)
if err != nil {
stats.FilerRequestCounter.WithLabelValues(stats.ErrorReadStream).Inc()
glog.Errorf("failed to stream content %s: %v", r.URL, err)