Skip to content

Commit

Permalink
Add KeepAlive settings between client and proxy (#41)
Browse files Browse the repository at this point in the history
* fix: switch server keepAlives

Signed-off-by: fum1h1to <[email protected]>

* fix: test

Signed-off-by: fum1h1to <[email protected]>

* fix: disableKeepAlives comment

Signed-off-by: fum1h1to <[email protected]>

* fix: review

Signed-off-by: fum1h1to <[email protected]>

---------

Signed-off-by: fum1h1to <[email protected]>
Co-authored-by: ly-2045544 <[email protected]>
  • Loading branch information
fum1h1to and ly-2045544 authored Aug 7, 2024
1 parent ea12753 commit 4bc56bb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ type Server struct {
// ShutdownDelay represents the delay duration between the health check server shutdown and the api server shutdown.
ShutdownDelay string `yaml:"shutdownDelay"`

// DisableKeepAlives represents whether HTTP keep-alive connections should be disabled between the client and the Provider Sidecar.
DisableKeepAlives bool `yaml:"disableKeepAlives"`

// TLS represents the TLS configuration of the authorization proxy.
TLS TLS `yaml:"tls"`

Expand Down
9 changes: 5 additions & 4 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ func TestNew(t *testing.T) {
want: &Config{
Version: "v2.0.0",
Server: Server{
Port: 8082,
Timeout: "10s",
ShutdownTimeout: "10s",
ShutdownDelay: "9s",
Port: 8082,
Timeout: "10s",
ShutdownTimeout: "10s",
ShutdownDelay: "9s",
DisableKeepAlives: true,
TLS: TLS{
Enable: true,
CertPath: "test/data/dummyServer.crt",
Expand Down
2 changes: 1 addition & 1 deletion service/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func NewServer(opts ...Option) (Server, error) {
Addr: fmt.Sprintf(":%d", s.cfg.Port),
Handler: s.srvHandler,
}
s.srv.SetKeepAlivesEnabled(true)
s.srv.SetKeepAlivesEnabled(!s.cfg.DisableKeepAlives)
if s.cfg.TLS.Enable {
s.srv.TLSConfig = s.tlsConfig
}
Expand Down
1 change: 1 addition & 0 deletions test/data/example_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ server:
timeout: 10s
shutdownTimeout: 10s
shutdownDelay: 9s
disableKeepAlives: true
tls:
enable: true
certPath: "test/data/dummyServer.crt"
Expand Down

0 comments on commit 4bc56bb

Please sign in to comment.