Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(relayproxy): Remove Timeout middleware #2864

Merged
merged 2 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions cmd/relayproxy/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"net/http"
"strings"
"time"

"github.com/aws/aws-lambda-go/lambda"
"github.com/labstack/echo-contrib/echoprometheus"
Expand Down Expand Up @@ -55,21 +54,6 @@ func (s *Server) initRoutes() {
s.apiEcho.HidePort = true
s.apiEcho.Debug = s.config.IsDebugEnabled()
s.apiEcho.Use(otelecho.Middleware("go-feature-flag"))
// Timeout middleware has to be the first middleware in the list
// (see: https://github.com/labstack/echo/blob/3b017855b4d331002e2b8b28e903679b875ae3e9/middleware/timeout.go#L17)
s.apiEcho.Use(middleware.TimeoutWithConfig(
middleware.TimeoutConfig{
Skipper: func(c echo.Context) bool {
// ignore websocket in the timeout
return strings.HasPrefix(c.Request().URL.String(), "/ws")
},
Timeout: time.Duration(s.config.RestAPITimeout) * time.Millisecond,
OnTimeoutRouteErrorHandler: func(err error, c echo.Context) {
s.zapLog.Error("Timeout on route", zap.String("route", c.Path()), zap.Error(err))
},
ErrorMessage: `Timeout on the server, please retry later`,
}),
)
s.apiEcho.Use(custommiddleware.ZapLogger(s.zapLog, s.config))
s.apiEcho.Use(middleware.BodyDumpWithConfig(middleware.BodyDumpConfig{
Skipper: func(c echo.Context) bool {
Expand Down
4 changes: 0 additions & 4 deletions cmd/relayproxy/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func New(flagSet *pflag.FlagSet, log *zap.Logger, version string) (*Config, erro
"listen": "1031",
"host": "localhost",
"fileFormat": "yaml",
"restApiTimeout": 5000,
"pollingInterval": 60000,
"logLevel": DefaultLogLevel,
}, "."), nil)
Expand Down Expand Up @@ -260,9 +259,6 @@ type Config struct {
// Notifiers is the configuration on where to notify a flag change
Notifiers []NotifierConf `mapstructure:"notifier" koanf:"notifier"`

// RestAPITimeout is the timeout on the API.
RestAPITimeout int `mapstructure:"restApiTimeout" koanf:"restapitimeout"`

// Version is the version of the relay-proxy
Version string `mapstructure:"version" koanf:"version"`

Expand Down
13 changes: 0 additions & 13 deletions cmd/relayproxy/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func TestParseConfig_fileFromPflag(t *testing.T) {
Kind: "log",
},
StartWithRetrieverError: false,
RestAPITimeout: 5000,
Version: "1.X.X",
EnableSwagger: true,
AuthorizedKeys: config.APIKeys{
Expand Down Expand Up @@ -75,7 +74,6 @@ func TestParseConfig_fileFromPflag(t *testing.T) {
},
},
StartWithRetrieverError: false,
RestAPITimeout: 5000,
Version: "1.X.X",
EnableSwagger: true,
AuthorizedKeys: config.APIKeys{
Expand Down Expand Up @@ -105,7 +103,6 @@ func TestParseConfig_fileFromPflag(t *testing.T) {
Kind: "log",
},
StartWithRetrieverError: false,
RestAPITimeout: 5000,
Version: "1.X.X",
EnableSwagger: true,
APIKeys: []string{
Expand Down Expand Up @@ -133,7 +130,6 @@ func TestParseConfig_fileFromPflag(t *testing.T) {
Kind: "log",
},
StartWithRetrieverError: false,
RestAPITimeout: 5000,
Version: "1.X.X",
EnableSwagger: true,
APIKeys: []string{
Expand All @@ -153,7 +149,6 @@ func TestParseConfig_fileFromPflag(t *testing.T) {
FileFormat: "yaml",
Host: "localhost",
StartWithRetrieverError: false,
RestAPITimeout: 5000,
Version: "1.X.X",
LogLevel: config.DefaultLogLevel,
},
Expand All @@ -172,7 +167,6 @@ func TestParseConfig_fileFromPflag(t *testing.T) {
PollingInterval: 60000,
FileFormat: "yaml",
Host: "localhost",
RestAPITimeout: 5000,
LogLevel: config.DefaultLogLevel,
Version: "1.X.X",
Retrievers: &[]config.RetrieverConf{
Expand Down Expand Up @@ -238,7 +232,6 @@ func TestParseConfig_fileFromFolder(t *testing.T) {
Kind: "log",
},
StartWithRetrieverError: false,
RestAPITimeout: 5000,
Version: "1.X.X",
EnableSwagger: true,
AuthorizedKeys: config.APIKeys{
Expand All @@ -263,7 +256,6 @@ func TestParseConfig_fileFromFolder(t *testing.T) {
FileFormat: "yaml",
Host: "localhost",
StartWithRetrieverError: false,
RestAPITimeout: 5000,
Version: "1.X.X",
LogLevel: config.DefaultLogLevel,
},
Expand All @@ -284,7 +276,6 @@ func TestParseConfig_fileFromFolder(t *testing.T) {
FileFormat: "yaml",
Host: "localhost",
StartWithRetrieverError: false,
RestAPITimeout: 5000,
Version: "1.X.X",
LogLevel: config.DefaultLogLevel,
},
Expand All @@ -299,7 +290,6 @@ func TestParseConfig_fileFromFolder(t *testing.T) {
FileFormat: "yaml",
Host: "localhost",
StartWithRetrieverError: false,
RestAPITimeout: 5000,
Version: "1.X.X",
LogLevel: config.DefaultLogLevel,
},
Expand All @@ -314,7 +304,6 @@ func TestParseConfig_fileFromFolder(t *testing.T) {
FileFormat: "yaml",
Host: "localhost",
StartWithRetrieverError: false,
RestAPITimeout: 5000,
Version: "1.X.X",
LogLevel: config.DefaultLogLevel,
},
Expand Down Expand Up @@ -837,7 +826,6 @@ func TestMergeConfig_FromOSEnv(t *testing.T) {
Kind: "log",
},
StartWithRetrieverError: false,
RestAPITimeout: 5000,
Version: "1.X.X",
EnableSwagger: true,
AuthorizedKeys: config.APIKeys{
Expand Down Expand Up @@ -870,7 +858,6 @@ func TestMergeConfig_FromOSEnv(t *testing.T) {
PollingInterval: 60000,
FileFormat: "yaml",
Host: "localhost",
RestAPITimeout: 5000,
LogLevel: config.DefaultLogLevel,
Version: "1.X.X",
Retrievers: &[]config.RetrieverConf{
Expand Down
1 change: 0 additions & 1 deletion website/docs/relay_proxy/configure_relay_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ ex: `AUTHORIZEDKEYS_EVALUATION=my-first-key,my-second-key`)_.
| `hideBanner` | boolean | `false` | Should we display the beautiful **go-feature-flag** banner when starting the relay proxy |
| `enableSwagger` | boolean | `false` | Enables Swagger for testing the APIs directly. If you are enabling Swagger you will have to provide the `host` configuration and the Swagger UI will be available at `http://<host>:<listen>/swagger/`. |
| `host` | string | `localhost` | This is the DNS you will use to access the relay proxy. This field is used by Swagger to query the API at the right place. |
| `restApiTimeout` | int | `5000` | Timeout in milliseconds for API calls. |
| `logLevel` | string | `info` | The log level to use for the relay proxy.<br/> Available values are `ERROR`, `WARN`, `INFO`, `DEBUG`. |
| `logFormat` | string | `json` | The format to use for structured logs from the relay proxy.<br/>Valid values are `json` and `logfmt`. |
| `fileFormat` | string | `yaml` | This is the format of your `go-feature-flag` configuration file. Acceptable values are `yaml`, `json`, `toml`. |
Expand Down
Loading