Skip to content
This repository was archived by the owner on Sep 24, 2025. It is now read-only.

Commit fdb4fe6

Browse files
committed
feat: Add flag to disable server|client keep-alives
1 parent 9d094a1 commit fdb4fe6

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

api/config_types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type ListenerOptionsT struct {
4040
ReadTimeout string `yaml:"readTimeout"`
4141
WriteTimeout string `yaml:"writeTimeout"`
4242
MaxConcurrentConnections int `yaml:"maxConcurrentConnections"`
43+
DisableKeepAlives bool `yaml:"disableKeepAlives"`
4344

4445
// Carry stuff
4546
ReadTimeoutDuration *time.Duration
@@ -105,8 +106,9 @@ type TargetTlsT struct {
105106
}
106107

107108
type TargetOptionsT struct {
108-
DialTimeout string `yaml:"dialTimeout"`
109-
KeepAlive string `yaml:"keepAlive"`
109+
DialTimeout string `yaml:"dialTimeout"`
110+
KeepAlive string `yaml:"keepAlive"`
111+
DisableKeepAlives bool `yaml:"disableKeepAlives"`
110112

111113
// Carry stuff
112114
DialTimeoutDuration *time.Duration

charts/bifrost/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ type: application
55
description: >-
66
A Helm chart for bifrost, a lightweight S3 proxy that re-signs requests between
77
your customers and buckets, supporting multiple client authentication methods.
8-
version: 0.6.0 # chart version
9-
appVersion: 0.6.0 # application version
8+
version: 0.7.0 # chart version
9+
appVersion: 0.7.0 # application version
1010
kubeVersion: ">=1.22.0-0" # kubernetes version
1111
home: https://github.com/freepik-company/bifrost
1212
sources:

docs/samples/bifrost.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ listener:
1010
options:
1111
readTimeout: 10s
1212
writeTimeout: 10s
13-
14-
# A value of 0 means no limit
15-
maxConcurrentConnections: 1000
13+
maxConcurrentConnections: 1000 # Zero (0) means no limit
14+
disableKeepAlives: false
1615

1716
# (Optional) Authentication configuration
1817
authentication:
@@ -65,3 +64,4 @@ target:
6564
options:
6665
dialTimeout: 10s
6766
keepAlive: 30s
67+
disableKeepAlives: false

internal/httpserver/httpserver.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ func (s *HttpServer) handleRequest(response http.ResponseWriter, request *http.R
294294
TLSClientConfig: &tls.Config{
295295
InsecureSkipVerify: globals.Application.Config.Target.Tls.SkipVerify,
296296
},
297+
298+
DisableKeepAlives: globals.Application.Config.Target.Options.DisableKeepAlives,
297299
},
298300
}
299301

@@ -382,12 +384,13 @@ func (s *HttpServer) Run(httpAddr string) {
382384

383385
globals.Application.Logger.Infof("Starting HTTP server on %s", httpAddr)
384386

385-
// TODO: Configure and use the server previously crafted
387+
// Configure and use the server previously crafted
386388
s.SetAddr(httpAddr)
387389
s.SetHandler(mux)
390+
s.SetKeepAlivesEnabled(!globals.Application.Config.Listener.Options.DisableKeepAlives)
388391

389392
//
390-
listener, err := net.Listen("tcp", s.Server.Addr)
393+
listener, err := net.Listen("tcp", s.Addr)
391394
if err != nil {
392395
globals.Application.Logger.Errorf("Server failed. Reason: %s", err.Error())
393396
}
@@ -397,7 +400,7 @@ func (s *HttpServer) Run(httpAddr string) {
397400
limitedListener = netutil.LimitListener(listener, globals.Application.Config.Listener.Options.MaxConcurrentConnections)
398401
}
399402

400-
err = s.Server.Serve(limitedListener)
403+
err = s.Serve(limitedListener)
401404
if err != nil {
402405
globals.Application.Logger.Errorf("Server failed. Reason: %s", err.Error())
403406
}

0 commit comments

Comments
 (0)