Rate limit sent data, not uncompressed

This commit is contained in:
Jakob Borg
2014-04-01 20:36:54 +02:00
parent 76e0960a51
commit a1f32095df
3 changed files with 36 additions and 20 deletions

View File

@@ -0,0 +1,19 @@
package main
import (
"io"
"github.com/juju/ratelimit"
)
type limitedWriter struct {
w io.Writer
bucket *ratelimit.Bucket
}
func (w *limitedWriter) Write(buf []byte) (int, error) {
if w.bucket != nil {
w.bucket.Wait(int64(len(buf)))
}
return w.w.Write(buf)
}