Skip to content

Commit 6646e26

Browse files
author
Chris Chapman
committed
Add in a first class configuration for envoy concurrency
1 parent beeff4d commit 6646e26

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

cmd/consul-dataplane/main.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"context"
55
"flag"
6+
"fmt"
67
"log"
78
"os"
89
"os/signal"
@@ -28,10 +29,11 @@ var (
2829

2930
useCentralTelemetryConfig bool
3031

31-
adminBindAddr string
32-
adminBindPort int
33-
readyBindAddr string
34-
readyBindPort int
32+
adminBindAddr string
33+
adminBindPort int
34+
readyBindAddr string
35+
readyBindPort int
36+
envoyConcurrency int
3537

3638
xdsBindAddr string
3739
xdsBindPort int
@@ -66,6 +68,7 @@ func init() {
6668
flag.IntVar(&adminBindPort, "envoy-admin-bind-port", 19000, "The port on which the Envoy admin server will be available.")
6769
flag.StringVar(&readyBindAddr, "envoy-ready-bind-address", "", "The address on which Envoy's readiness probe will be available.")
6870
flag.IntVar(&readyBindPort, "envoy-ready-bind-port", 0, "The port on which Envoy's readiness probe will be available.")
71+
flag.IntVar(&envoyConcurrency, "envoy-concurrency", 2, "The envoy concurrency denotes the number of threads that envoy will use https://www.envoyproxy.io/docs/envoy/latest/operations/cli#cmdoption-concurrency.")
6972

7073
flag.StringVar(&xdsBindAddr, "xds-bind-addr", "127.0.0.1", "The address on which the Envoy xDS server will be available.")
7174
flag.IntVar(&xdsBindPort, "xds-bind-port", 0, "The port on which the Envoy xDS server will be available.")
@@ -80,14 +83,23 @@ func validateFlags() {
8083
}
8184
}
8285

86+
func extraEnvoyArguments() []string {
87+
extraEnvoyArgs := flag.Args()
88+
if extraEnvoyArgs == nil {
89+
extraEnvoyArgs = []string{}
90+
}
91+
concurrency := fmt.Sprintf("--concurrency %v", envoyConcurrency)
92+
// to ensure precedence of arguements we prepend before extraArgs so that subsequent params override the
93+
// last set value
94+
return append([]string{concurrency}, extraEnvoyArgs...)
95+
}
96+
8397
func main() {
8498

8599
flag.Parse()
86100

87101
validateFlags()
88102

89-
extraEnvoyArgs := flag.Args()
90-
91103
consuldpCfg := &consuldp.Config{
92104
Consul: &consuldp.ConsulConfig{
93105
Addresses: addresses,
@@ -118,7 +130,7 @@ func main() {
118130
AdminBindPort: adminBindPort,
119131
ReadyBindAddress: readyBindAddr,
120132
ReadyBindPort: readyBindPort,
121-
ExtraArgs: extraEnvoyArgs,
133+
ExtraArgs: extraEnvoyArguments(),
122134
},
123135
XDSServer: &consuldp.XDSServer{
124136
BindAddress: xdsBindAddr,

0 commit comments

Comments
 (0)