AddDataBytes adds the queried data bytes and returns an error if the limit is reached.
(dataSizeInBytes int)
| 109 | |
| 110 | // AddDataBytes adds the queried data bytes and returns an error if the limit is reached. |
| 111 | func (ql *QueryLimiter) AddDataBytes(dataSizeInBytes int) error { |
| 112 | if ql.maxDataBytesPerQuery == 0 { |
| 113 | return nil |
| 114 | } |
| 115 | if ql.dataBytesCount.Add(int64(dataSizeInBytes)) > int64(ql.maxDataBytesPerQuery) { |
| 116 | return fmt.Errorf(ErrMaxDataBytesHit, ql.maxDataBytesPerQuery) |
| 117 | } |
| 118 | return nil |
| 119 | } |
| 120 | |
| 121 | func (ql *QueryLimiter) AddChunks(count int) error { |
| 122 | if ql.maxChunksPerQuery == 0 { |