Skip to content

Commit

Permalink
adding dapr-http-read-buffer-size parameter to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
hueifeng committed Jun 3, 2022
1 parent 9bfc538 commit 6ba84e5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var (
appSSL bool
metricsPort int
maxRequestBodySize int
readBufferSize int
unixDomainSocket string
enableAPILogging bool
)
Expand Down Expand Up @@ -115,6 +116,7 @@ dapr run --app-id myapp --app-port 3000 --app-protocol grpc -- go run main.go
AppSSL: appSSL,
MetricsPort: metricsPort,
MaxRequestBodySize: maxRequestBodySize,
HTTPReadBufferSize: readBufferSize,
UnixDomainSocket: unixDomainSocket,
EnableAPILogging: enableAPILogging,
})
Expand Down Expand Up @@ -364,6 +366,7 @@ func init() {
RunCmd.Flags().IntVarP(&metricsPort, "metrics-port", "M", -1, "The port of metrics on dapr")
RunCmd.Flags().BoolP("help", "h", false, "Print this help message")
RunCmd.Flags().IntVarP(&maxRequestBodySize, "dapr-http-max-request-size", "", -1, "Max size of request body in MB")
RunCmd.Flags().IntVarP(&readBufferSize, "dapr-http-read-buffer-size", "", -1, "HTTP header read buffer in KB")
RunCmd.Flags().StringVarP(&unixDomainSocket, "unix-domain-socket", "u", "", "Path to a unix domain socket dir. If specified, Dapr API servers will use Unix Domain Sockets")
RunCmd.Flags().BoolVar(&enableAPILogging, "enable-api-logging", false, "Log API calls at INFO verbosity. Valid values are: true or false")

Expand Down
2 changes: 1 addition & 1 deletion install/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# ------------------------------------------------------------
param (
[string]$Version,
[string]$DaprRoot = "$Env:SystemDrive\dapr",
[string]$DaprRoot = "c:\dapr",
[string]$DaprReleaseJsonUrl = "",
[scriptblock]$CustomAssetFactory = $null
)
Expand Down
7 changes: 7 additions & 0 deletions pkg/standalone/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type runData struct {
appCmd string
enableMetrics bool
maxRequestBodySize int
httpReadBufferSize int
}

func (d *daprProcess) List() ([]ListOutput, error) {
Expand Down Expand Up @@ -134,6 +135,11 @@ func List() ([]ListOutput, error) {
continue
}

httpReadBufferSize, err := strconv.Atoi(argumentsMap["--dapr-http-read-buffer-size"])
if err != nil {
continue
}

run := runData{
cliPID: cliPID,
sidecarPID: proc.Pid(),
Expand All @@ -144,6 +150,7 @@ func List() ([]ListOutput, error) {
appCmd: appCmd,
enableMetrics: enableMetrics,
maxRequestBodySize: maxRequestBodySize,
httpReadBufferSize: httpReadBufferSize,
}

cliToSidecarMap[cliPID] = &run
Expand Down
5 changes: 5 additions & 0 deletions pkg/standalone/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type RunConfig struct {
AppSSL bool `arg:"app-ssl"`
MetricsPort int `env:"DAPR_METRICS_PORT" arg:"metrics-port"`
MaxRequestBodySize int `arg:"dapr-http-max-request-size"`
HTTPReadBufferSize int `arg:"dapr-http-read-buffer-size"`
UnixDomainSocket string `arg:"unix-domain-socket"`
EnableAPILogging bool `arg:"enable-api-logging"`
}
Expand Down Expand Up @@ -158,6 +159,10 @@ func (config *RunConfig) validate() error {
config.MaxRequestBodySize = -1
}

if config.HTTPReadBufferSize < 0 {
config.HTTPReadBufferSize = -1
}

err = config.validatePlacementHostAddr()
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions pkg/standalone/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func assertCommonArgs(t *testing.T, basicConfig *RunConfig, output *RunOutput) {
assertArgumentEqual(t, "app-ssl", "", output.DaprCMD.Args)
assertArgumentEqual(t, "metrics-port", "9001", output.DaprCMD.Args)
assertArgumentEqual(t, "dapr-http-max-request-size", "-1", output.DaprCMD.Args)
assertArgumentEqual(t, "dapr-http-read-buffer-size", "-1", output.DaprCMD.Args)
}

func assertAppEnv(t *testing.T, config *RunConfig, output *RunOutput) {
Expand Down Expand Up @@ -148,6 +149,7 @@ func TestRun(t *testing.T) {
AppSSL: true,
MetricsPort: 9001,
MaxRequestBodySize: -1,
HTTPReadBufferSize: -1,
EnableAPILogging: true,
}

Expand Down

0 comments on commit 6ba84e5

Please sign in to comment.