Skip to content

Commit 4bc56bb

Browse files
fsul7oly-2045544
andauthored
Add KeepAlive settings between client and proxy (#41)
* fix: switch server keepAlives Signed-off-by: fum1h1to <75571344+fum1h1to@users.noreply.github.com> * fix: test Signed-off-by: fum1h1to <75571344+fum1h1to@users.noreply.github.com> * fix: disableKeepAlives comment Signed-off-by: fum1h1to <75571344+fum1h1to@users.noreply.github.com> * fix: review Signed-off-by: fum1h1to <75571344+fum1h1to@users.noreply.github.com> --------- Signed-off-by: fum1h1to <75571344+fum1h1to@users.noreply.github.com> Co-authored-by: ly-2045544 <ly-2045544@yahoo-corp.jp>
1 parent ea12753 commit 4bc56bb

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

config/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ type Server struct {
6464
// ShutdownDelay represents the delay duration between the health check server shutdown and the api server shutdown.
6565
ShutdownDelay string `yaml:"shutdownDelay"`
6666

67+
// DisableKeepAlives represents whether HTTP keep-alive connections should be disabled between the client and the Provider Sidecar.
68+
DisableKeepAlives bool `yaml:"disableKeepAlives"`
69+
6770
// TLS represents the TLS configuration of the authorization proxy.
6871
TLS TLS `yaml:"tls"`
6972

config/config_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ func TestNew(t *testing.T) {
7777
want: &Config{
7878
Version: "v2.0.0",
7979
Server: Server{
80-
Port: 8082,
81-
Timeout: "10s",
82-
ShutdownTimeout: "10s",
83-
ShutdownDelay: "9s",
80+
Port: 8082,
81+
Timeout: "10s",
82+
ShutdownTimeout: "10s",
83+
ShutdownDelay: "9s",
84+
DisableKeepAlives: true,
8485
TLS: TLS{
8586
Enable: true,
8687
CertPath: "test/data/dummyServer.crt",

service/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func NewServer(opts ...Option) (Server, error) {
126126
Addr: fmt.Sprintf(":%d", s.cfg.Port),
127127
Handler: s.srvHandler,
128128
}
129-
s.srv.SetKeepAlivesEnabled(true)
129+
s.srv.SetKeepAlivesEnabled(!s.cfg.DisableKeepAlives)
130130
if s.cfg.TLS.Enable {
131131
s.srv.TLSConfig = s.tlsConfig
132132
}

test/data/example_config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ server:
55
timeout: 10s
66
shutdownTimeout: 10s
77
shutdownDelay: 9s
8+
disableKeepAlives: true
89
tls:
910
enable: true
1011
certPath: "test/data/dummyServer.crt"

0 commit comments

Comments
 (0)