From ad69ae892a8e726d63f32d017992350414cc6914 Mon Sep 17 00:00:00 2001 From: Mostafa Moradian Date: Sun, 8 Oct 2023 00:37:20 +0200 Subject: [PATCH] Remove unused Server options --- cmd/run.go | 38 ++------------------------------------ config/config.go | 19 ++++--------------- config/getters.go | 17 ----------------- config/types.go | 29 ++++------------------------- gatewayd.yaml | 11 ----------- 5 files changed, 10 insertions(+), 104 deletions(-) diff --git a/cmd/run.go b/cmd/run.go index 4d7bb407..7aba4a41 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -30,7 +30,6 @@ import ( usage "github.com/gatewayd-io/gatewayd/usagereport/v1" "github.com/getsentry/sentry-go" "github.com/go-co-op/gocron" - "github.com/panjf2000/gnet/v2" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/rs/zerolog" @@ -633,30 +632,9 @@ var runCmd = &cobra.Command{ cfg.Network, cfg.Address, cfg.GetTickInterval(), - []gnet.Option{ - // Scheduling options - gnet.WithMulticore(cfg.MultiCore), - gnet.WithLockOSThread(cfg.LockOSThread), - // NumEventLoop overrides Multicore option. - // gnet.WithNumEventLoop(1), - + network.Option{ // Can be used to send keepalive messages to the client. - gnet.WithTicker(cfg.EnableTicker), - - // Internal event-loop load balancing options - gnet.WithLoadBalancing(cfg.GetLoadBalancer()), - - // Buffer options - gnet.WithReadBufferCap(cfg.ReadBufferCap), - gnet.WithWriteBufferCap(cfg.WriteBufferCap), - gnet.WithSocketRecvBuffer(cfg.SocketRecvBuffer), - gnet.WithSocketSendBuffer(cfg.SocketSendBuffer), - - // TCP options - gnet.WithReuseAddr(cfg.ReuseAddress), - gnet.WithReusePort(cfg.ReusePort), - gnet.WithTCPKeepAlive(cfg.TCPKeepAlive), - gnet.WithTCPNoDelay(cfg.GetTCPNoDelay()), + EnableTicker: cfg.EnableTicker, }, proxies[name], logger, @@ -669,18 +647,6 @@ var runCmd = &cobra.Command{ attribute.String("network", cfg.Network), attribute.String("address", cfg.Address), attribute.String("tickInterval", cfg.TickInterval.String()), - attribute.Bool("multiCore", cfg.MultiCore), - attribute.Bool("lockOSThread", cfg.LockOSThread), - attribute.Bool("enableTicker", cfg.EnableTicker), - attribute.String("loadBalancer", cfg.LoadBalancer), - attribute.Int("readBufferCap", cfg.ReadBufferCap), - attribute.Int("writeBufferCap", cfg.WriteBufferCap), - attribute.Int("socketRecvBuffer", cfg.SocketRecvBuffer), - attribute.Int("socketSendBuffer", cfg.SocketSendBuffer), - attribute.Bool("reuseAddress", cfg.ReuseAddress), - attribute.Bool("reusePort", cfg.ReusePort), - attribute.String("tcpKeepAlive", cfg.TCPKeepAlive.String()), - attribute.Bool("tcpNoDelay", cfg.TCPNoDelay), attribute.String("pluginTimeout", conf.Plugin.Timeout.String()), )) diff --git a/config/config.go b/config/config.go index e2d38f9b..34b97279 100644 --- a/config/config.go +++ b/config/config.go @@ -129,21 +129,10 @@ func (c *Config) LoadDefaults(ctx context.Context) { } defaultServer := Server{ - Network: DefaultListenNetwork, - Address: DefaultListenAddress, - EnableTicker: false, - TickInterval: DefaultTickInterval, - MultiCore: true, - LockOSThread: false, - ReuseAddress: true, - ReusePort: true, - LoadBalancer: DefaultLoadBalancer, - ReadBufferCap: DefaultBufferSize, - WriteBufferCap: DefaultBufferSize, - SocketRecvBuffer: DefaultBufferSize, - SocketSendBuffer: DefaultBufferSize, - TCPKeepAlive: DefaultTCPKeepAliveDuration, - TCPNoDelay: DefaultTCPNoDelay, + Network: DefaultListenNetwork, + Address: DefaultListenAddress, + EnableTicker: false, + TickInterval: DefaultTickInterval, } c.globalDefaults = GlobalConfig{ diff --git a/config/getters.go b/config/getters.go index 11a8aa3b..da5aff20 100644 --- a/config/getters.go +++ b/config/getters.go @@ -166,23 +166,6 @@ func (s Server) GetTickInterval() time.Duration { return s.TickInterval } -// GetLoadBalancer returns the load balancing algorithm to use. -func (s Server) GetLoadBalancer() gnet.LoadBalancing { - if lb, ok := loadBalancers[s.LoadBalancer]; ok { - return lb - } - return gnet.RoundRobin -} - -// GetTCPNoDelay returns the TCP no delay option from config file. -func (s Server) GetTCPNoDelay() gnet.TCPSocketOpt { - if s.TCPNoDelay { - return gnet.TCPNoDelay - } - - return gnet.TCPDelay -} - // GetSize returns the pool size from config file. func (p Pool) GetSize() int { if p.Size == 0 { diff --git a/config/types.go b/config/types.go index 5924e855..d1a499b3 100644 --- a/config/types.go +++ b/config/types.go @@ -5,16 +5,6 @@ import ( "time" ) -// // getPath returns the path to the referenced config value. -// func getPath(cfg *koanf.Koanf, path string) string { -// ref := cfg.String(path) -// if cfg.Exists(path) && cfg.StringMap(ref) != nil { -// return ref -// } - -// return path -// } - type Plugin struct { Name string `json:"name" jsonschema:"required"` Enabled bool `json:"enabled"` @@ -88,21 +78,10 @@ type Proxy struct { } type Server struct { - EnableTicker bool `json:"enableTicker"` - MultiCore bool `json:"multiCore"` - LockOSThread bool `json:"lockOSThread"` //nolint:tagliatelle - ReuseAddress bool `json:"reuseAddress"` - ReusePort bool `json:"reusePort"` - TCPNoDelay bool `json:"tcpNoDelay"` - ReadBufferCap int `json:"readBufferCap"` - WriteBufferCap int `json:"writeBufferCap"` - SocketRecvBuffer int `json:"socketRecvBuffer"` - SocketSendBuffer int `json:"socketSendBuffer"` - TCPKeepAlive time.Duration `json:"tcpKeepAlive" jsonschema:"oneof_type=string;integer"` - TickInterval time.Duration `json:"tickInterval" jsonschema:"oneof_type=string;integer"` - Network string `json:"network" jsonschema:"enum=tcp,enum=udp,enum=unix"` - Address string `json:"address"` - LoadBalancer string `json:"loadBalancer" jsonschema:"enum=roundrobin,enum=leastconnections,enum=sourceaddrhash"` + EnableTicker bool `json:"enableTicker"` + TickInterval time.Duration `json:"tickInterval" jsonschema:"oneof_type=string;integer"` + Network string `json:"network" jsonschema:"enum=tcp,enum=udp,enum=unix"` + Address string `json:"address"` } type API struct { diff --git a/gatewayd.yaml b/gatewayd.yaml index f0032f2d..d30880dc 100644 --- a/gatewayd.yaml +++ b/gatewayd.yaml @@ -56,17 +56,6 @@ servers: address: 0.0.0.0:15432 enableTicker: False tickInterval: 5s # duration - multiCore: True - lockOSThread: False - loadBalancer: roundrobin - readBufferCap: 134217728 - writeBufferCap: 134217728 - socketRecvBuffer: 134217728 - socketSendBuffer: 134217728 - reuseAddress: True - reusePort: True - tcpKeepAlive: 3s # duration - tcpNoDelay: True api: enabled: True