Skip to content

Commit

Permalink
increasing bufio buffer size to 10mb (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
msarvar authored Sep 28, 2021
1 parent f1d2f57 commit f2b15c4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/events/terraform/terraform_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ import (

var LogStreamingValidCmds = [...]string{"init", "plan", "apply"}

// Setting the buffer size to 10mb
const BufioScannerBufferSize = 10 * 1024 * 1024

//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_terraform_client.go Client

type Client interface {
Expand Down Expand Up @@ -440,11 +443,13 @@ func (c *DefaultClient) RunCommandAsync(ctx models.ProjectCommandContext, path s
// Use a waitgroup to block until our stdout/err copying is complete.
wg := new(sync.WaitGroup)
wg.Add(2)

// Asynchronously copy from stdout/err to outCh.
go func() {
c.projectCmdOutputHandler.Send(ctx, fmt.Sprintf("\n----- running terraform %s -----", args[0]))
s := bufio.NewScanner(stdout)
buf := []byte{}
s.Buffer(buf, BufioScannerBufferSize)

for s.Scan() {
message := s.Text()
outCh <- Line{Line: message}
Expand Down

0 comments on commit f2b15c4

Please sign in to comment.