Skip to content

Commit

Permalink
Merge pull request #139 from fesd/max-ammo-size
Browse files Browse the repository at this point in the history
added MaxAmmoSize option to the http/json ammo provider
  • Loading branch information
trueival authored Oct 29, 2020
2 parents 26c74ba + c98ed80 commit 4bc9e68
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions components/phttp/ammo/simple/jsonline/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ type Config struct {
// Passes limits ammo file passes. Unlimited if zero.
Passes int `validate:"min=0"`
ContinueOnError bool
//Maximum number of byte in an ammo. Default is bufio.MaxScanTokenSize
MaxAmmoSize int
}

func (p *Provider) start(ctx context.Context, ammoFile afero.File) error {
var ammoNum, passNum int
for {
passNum++
scanner := bufio.NewScanner(ammoFile)
if p.Config.MaxAmmoSize != 0 {
var buffer []byte
scanner.Buffer(buffer, p.Config.MaxAmmoSize)
}
for line := 1; scanner.Scan() && (p.Limit == 0 || ammoNum < p.Limit); line++ {
data := scanner.Bytes()
a, err := decodeAmmo(data, p.Pool.Get().(*simple.Ammo))
Expand Down

0 comments on commit 4bc9e68

Please sign in to comment.