(conn net.Conn, limit *LimitFallback)
| 120 | } |
| 121 | |
| 122 | func NewRatelimitedConn(conn net.Conn, limit *LimitFallback) net.Conn { |
| 123 | if limit.BytesPerSec == 0 { |
| 124 | return conn |
| 125 | } |
| 126 | |
| 127 | burstBytesPerSec := limit.BurstBytesPerSec |
| 128 | if burstBytesPerSec < limit.BytesPerSec { |
| 129 | burstBytesPerSec = limit.BytesPerSec |
| 130 | } |
| 131 | |
| 132 | return &RatelimitedConn{ |
| 133 | Conn: conn, |
| 134 | After: int64(limit.AfterBytes), |
| 135 | Bucket: ratelimit.NewBucketWithRate(float64(limit.BytesPerSec), int64(burstBytesPerSec)), |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | var ( |
| 140 | size = 8192 |
no outgoing calls
no test coverage detected
searching dependent graphs…