Skip to content

Commit

Permalink
chore: remove timeout feature (buggy)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Oct 23, 2024
1 parent c02c5e5 commit d7dd78c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 223 deletions.
35 changes: 8 additions & 27 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/formancehq/go-libs/v2/health"
"github.com/formancehq/go-libs/v2/httpserver"
"github.com/formancehq/go-libs/v2/otlp"
"github.com/formancehq/ledger/internal/api/common"
"github.com/formancehq/ledger/internal/storage/driver"
"github.com/go-chi/chi/v5"
"go.opentelemetry.io/otel/sdk/metric"
Expand All @@ -32,14 +31,12 @@ import (
)

const (
BindFlag = "bind"
BallastSizeInBytesFlag = "ballast-size"
NumscriptCacheMaxCountFlag = "numscript-cache-max-count"
AutoUpgradeFlag = "auto-upgrade"
APIResponsesTimeoutDelayFlag = "api-responses-timeout-delay"
APIResponsesTimeoutStatusCodeFlag = "api-responses-timeout-status-code"
ExperimentalFeaturesFlag = "experimental-features"
BulkMaxSizeFlag = "bulk-max-size"
BindFlag = "bind"
BallastSizeInBytesFlag = "ballast-size"
NumscriptCacheMaxCountFlag = "numscript-cache-max-count"
AutoUpgradeFlag = "auto-upgrade"
ExperimentalFeaturesFlag = "experimental-features"
BulkMaxSizeFlag = "bulk-max-size"
)

func NewServeCommand() *cobra.Command {
Expand All @@ -59,16 +56,6 @@ func NewServeCommand() *cobra.Command {
return err
}

apiResponseTimeoutDelay, err := cmd.Flags().GetDuration(APIResponsesTimeoutDelayFlag)
if err != nil {
return err
}

apiResponseTimeoutStatusCode, err := cmd.Flags().GetInt(APIResponsesTimeoutStatusCodeFlag)
if err != nil {
return err
}

bulkMaxSize, err := cmd.Flags().GetInt(BulkMaxSizeFlag)
if err != nil {
return err
Expand Down Expand Up @@ -96,12 +83,8 @@ func NewServeCommand() *cobra.Command {
bus.NewFxModule(),
ballast.Module(serveConfiguration.ballastSize),
api.Module(api.Config{
Version: Version,
Debug: service.IsDebug(cmd),
Timeout: common.TimeoutConfiguration{
Timeout: apiResponseTimeoutDelay,
StatusCode: apiResponseTimeoutStatusCode,
},
Version: Version,
Debug: service.IsDebug(cmd),
BulkMaxSize: bulkMaxSize,
}),
fx.Decorate(func(
Expand Down Expand Up @@ -136,8 +119,6 @@ func NewServeCommand() *cobra.Command {
cmd.Flags().Bool(AutoUpgradeFlag, false, "Automatically upgrade all schemas")
cmd.Flags().String(BindFlag, "0.0.0.0:3068", "API bind address")
cmd.Flags().Bool(ExperimentalFeaturesFlag, false, "Enable features configurability")
cmd.Flags().Duration(APIResponsesTimeoutDelayFlag, 0, "API response timeout delay")
cmd.Flags().Int(APIResponsesTimeoutStatusCodeFlag, http.StatusGatewayTimeout, "API response timeout status code")
cmd.Flags().Int(BulkMaxSizeFlag, api.DefaultBulkMaxSize, "Bulk max size (default 100)")

service.AddFlags(cmd.Flags())
Expand Down
96 changes: 0 additions & 96 deletions internal/api/common/middlewares_timeout.go

This file was deleted.

3 changes: 0 additions & 3 deletions internal/api/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/formancehq/go-libs/v2/auth"
"github.com/formancehq/go-libs/v2/health"
"github.com/formancehq/go-libs/v2/logging"
"github.com/formancehq/ledger/internal/api/common"
"github.com/formancehq/ledger/internal/controller/system"
"github.com/go-chi/chi/v5"
"go.opentelemetry.io/otel/trace"
Expand All @@ -15,7 +14,6 @@ import (
type Config struct {
Version string
Debug bool
Timeout common.TimeoutConfiguration
BulkMaxSize int
}

Expand All @@ -34,7 +32,6 @@ func Module(cfg Config) fx.Option {
"develop",
cfg.Debug,
WithTracer(tracer.Tracer("api")),
WithTimeout(cfg.Timeout),
WithBulkMaxSize(cfg.BulkMaxSize),
)
}),
Expand Down
14 changes: 2 additions & 12 deletions internal/api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ func NewRouter(
commonMiddlewares := []func(http.Handler) http.Handler{
middleware.RequestLogger(api.NewLogFormatter()),
}
if routerOptions.timeoutConfiguration.Timeout != 0 {
commonMiddlewares = append(commonMiddlewares, common.Timeout(routerOptions.timeoutConfiguration))
}

v2Router := v2.NewRouter(
systemController,
Expand All @@ -85,9 +82,8 @@ func NewRouter(
}

type routerOptions struct {
tracer trace.Tracer
timeoutConfiguration common.TimeoutConfiguration
bulkMaxSize int
tracer trace.Tracer
bulkMaxSize int
}

type RouterOption func(ro *routerOptions)
Expand All @@ -98,12 +94,6 @@ func WithTracer(tracer trace.Tracer) RouterOption {
}
}

func WithTimeout(timeoutConfiguration common.TimeoutConfiguration) RouterOption {
return func(ro *routerOptions) {
ro.timeoutConfiguration = timeoutConfiguration
}
}

func WithBulkMaxSize(bulkMaxSize int) RouterOption {
return func(ro *routerOptions) {
ro.bulkMaxSize = bulkMaxSize
Expand Down
8 changes: 0 additions & 8 deletions pkg/testserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type Configuration struct {
Debug bool
OTLPConfig *OTLPConfig
ExperimentalFeatures bool
APIResponseTimeout time.Duration
BulkMaxSize int
}

Expand Down Expand Up @@ -75,13 +74,6 @@ func (s *Server) Start() {
"--"+cmd.ExperimentalFeaturesFlag,
)
}
if s.configuration.APIResponseTimeout != 0 {
args = append(
args,
"--"+cmd.APIResponsesTimeoutDelayFlag,
s.configuration.APIResponseTimeout.String(),
)
}
if s.configuration.BulkMaxSize != 0 {
args = append(
args,
Expand Down
77 changes: 0 additions & 77 deletions test/e2e/api_timeout_test.go

This file was deleted.

0 comments on commit d7dd78c

Please sign in to comment.