support setting a maximum number of readers per path (#1286) (#2154)

This commit is contained in:
Alessandro Ros
2023-08-05 17:41:54 +02:00
committed by GitHub
parent b198cc5952
commit d00b22b5e5
6 changed files with 323 additions and 263 deletions

View File

@@ -866,6 +866,13 @@ func (pa *path) handleAddReader(req pathAddReaderReq) {
}
func (pa *path) handleAddReaderPost(req pathAddReaderReq) {
if pa.conf.MaxReaders != 0 && len(pa.readers) >= pa.conf.MaxReaders {
req.res <- pathAddReaderRes{
err: fmt.Errorf("maximum reader count reached"),
}
return
}
pa.readers[req.author] = struct{}{}
if pa.conf.HasOnDemandStaticSource() {