Skip to content

Commit

Permalink
Add hidden --parallelism flag (#2745)
Browse files Browse the repository at this point in the history
  • Loading branch information
bufdev authored Jan 31, 2024
1 parent 31ed3f1 commit b99366e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions private/pkg/app/appflag/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/bufbuild/buf/private/pkg/app/applog"
"github.com/bufbuild/buf/private/pkg/app/appverbose"
"github.com/bufbuild/buf/private/pkg/observabilityzap"
"github.com/bufbuild/buf/private/pkg/thread"
"github.com/pkg/profile"
"github.com/spf13/pflag"
"go.uber.org/multierr"
Expand All @@ -44,6 +45,8 @@ type builder struct {
profileType string
profileAllowError bool

parallelism int

timeout time.Duration

defaultTimeout time.Duration
Expand Down Expand Up @@ -83,6 +86,8 @@ func (b *builder) BindRoot(flagSet *pflag.FlagSet) {
// We do not officially support this flag, this is for testing, where we need warnings turned off.
flagSet.BoolVar(&b.noWarn, "no-warn", false, "Turn off warn logging")
_ = flagSet.MarkHidden("no-warn")
flagSet.IntVar(&b.parallelism, "parallelism", 0, "Manually control the parallelism")
_ = flagSet.MarkHidden("parallelism")
}

func (b *builder) NewRunFunc(
Expand Down Expand Up @@ -120,6 +125,10 @@ func (b *builder) run(
return err
}

if b.parallelism > 0 {
thread.SetParallelism(b.parallelism)
}

var cancel context.CancelFunc
if !b.profile && b.timeout != 0 {
ctx, cancel = context.WithTimeout(ctx, b.timeout)
Expand Down

0 comments on commit b99366e

Please sign in to comment.