Skip to content

Commit

Permalink
formatting improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
slahirucd7 committed Dec 3, 2024
1 parent 447ba25 commit ff3de82
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion adapter/cmd/adapter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func startMicroGateway() {
logger.Fatal("Error starting the adapter", err)
}
conf, errReadConfig := config.ReadConfigs()
config.GetTcpKeepaliveEnabledOrgs()
config.GetTCPKeepaliveEnabledOrgs()
if errReadConfig != nil {
logger.Fatal("Error loading configuration. ", errReadConfig)
}
Expand Down
7 changes: 3 additions & 4 deletions adapter/config/default_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,13 @@ var defaultConfig = &Config{
MaxRetries: 50,
},
},
TcpConfigurations: upstreamTcpConfigs{
TCPConfigurations: upstreamTCPConfigs{
KeepaliveTimeInMillis: 120000,
KeepaliveProbes: 9,
KeepaliveIntervalInMillis: 75,
KeepaliveIntervalInMillis: 75000,
},
HttpConfigurations: upstreamHttpConfigs{
HTTPConfigurations: upstreamHTTPConfigs{
IdleTimeoutInMillis: 120000,
MaxConnectionDurationInMillis: 120000,
},
},
Connection: connection{
Expand Down
5 changes: 3 additions & 2 deletions adapter/config/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var (
adapterConfig *Config
defaultVhost map[string]string
e error
// UpstreamConnectionConfEnabledOrgList is the list of orgs that need to handle connection timeouts
UpstreamConnectionConfEnabledOrgList []string
)

Expand Down Expand Up @@ -257,8 +258,8 @@ func printDeprecatedWarningLog(deprecatedTerm, currentTerm string) {
logger.Warnf("%s is deprecated. Use %s instead", deprecatedTerm, currentTerm)
}

// GetTcpKeepaliveEnabledOrgs returns the list of orgs that need to handle connection timeouts
func GetTcpKeepaliveEnabledOrgs() {
// GetTCPKeepaliveEnabledOrgs returns the list of orgs that need to handle connection timeouts
func GetTCPKeepaliveEnabledOrgs() {
orgs := os.Getenv("TCP_KEEPALIVE_ENABLED_ORGS")
UpstreamConnectionConfEnabledOrgList = strings.Split(orgs, ",")
if len(UpstreamConnectionConfEnabledOrgList) == 0 {
Expand Down
9 changes: 4 additions & 5 deletions adapter/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ type envoyUpstream struct {
DNS upstreamDNS
Retry upstreamRetry
CircuitBreakers []upstreamCircuitBreaker
TcpConfigurations upstreamTcpConfigs
HttpConfigurations upstreamHttpConfigs
TCPConfigurations upstreamTCPConfigs
HTTPConfigurations upstreamHTTPConfigs
}

type upstreamTLS struct {
Expand Down Expand Up @@ -278,14 +278,13 @@ type dnsResolverConfig struct {
CAres cAres
}

type upstreamTcpConfigs struct {
type upstreamTCPConfigs struct {
KeepaliveTimeInMillis uint32
KeepaliveProbes uint32
KeepaliveIntervalInMillis uint32
}
type upstreamHttpConfigs struct {
type upstreamHTTPConfigs struct {
IdleTimeoutInMillis uint32
MaxConnectionDurationInMillis uint32
}

type dnsResolverType string
Expand Down
9 changes: 4 additions & 5 deletions adapter/internal/oasparser/envoyconf/routes_with_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,15 @@ func getClusterName(epPrefix string, organizationID string, vHost string, swagge
func getKeepAliveConfigs(cluster *clusterv3.Cluster, conf *config.Config) {
cluster.UpstreamConnectionOptions = &clusterv3.UpstreamConnectionOptions{
TcpKeepalive: &corev3.TcpKeepalive{
KeepaliveProbes: wrapperspb.UInt32(conf.Envoy.Upstream.TcpConfigurations.KeepaliveProbes),
KeepaliveInterval: wrapperspb.UInt32(conf.Envoy.Upstream.TcpConfigurations.KeepaliveIntervalInMillis),
KeepaliveTime: wrapperspb.UInt32(conf.Envoy.Upstream.TcpConfigurations.KeepaliveTimeInMillis / 1000),
KeepaliveProbes: wrapperspb.UInt32(conf.Envoy.Upstream.TCPConfigurations.KeepaliveProbes),
KeepaliveInterval: wrapperspb.UInt32(conf.Envoy.Upstream.TCPConfigurations.KeepaliveIntervalInMillis / 1000),
KeepaliveTime: wrapperspb.UInt32(conf.Envoy.Upstream.TCPConfigurations.KeepaliveTimeInMillis / 1000),
},
}

config := &upstreams.HttpProtocolOptions{
CommonHttpProtocolOptions: &corev3.HttpProtocolOptions{
IdleTimeout: durationpb.New(time.Duration(conf.Envoy.Upstream.HttpConfigurations.IdleTimeoutInMillis) * time.Millisecond),
MaxConnectionDuration: durationpb.New(time.Duration(conf.Envoy.Upstream.HttpConfigurations.MaxConnectionDurationInMillis) * time.Millisecond),
IdleTimeout: durationpb.New(time.Duration(conf.Envoy.Upstream.HTTPConfigurations.IdleTimeoutInMillis) * time.Millisecond),
},
UpstreamProtocolOptions: &upstreams.HttpProtocolOptions_UseDownstreamProtocolConfig{},
}
Expand Down
8 changes: 3 additions & 5 deletions resources/conf/config.toml.template
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,18 @@ retainKeys = ["self_validate_jwt", "issuer", "claim_mappings", "consumer_key_cla
maxInterval = "500ms"

# TCP configurations applicable with the upstream clusters
[router.upstream.tcpConfigurations]
[router.upstream.tCPConfigurations]
# The number of milliseconds a connection needs to be idle before keep-alive probes start being sent
keepaliveTimeInMillis = 120000
# Maximum number of keep-alive probes to send without response before deciding the connection is dead
keepaliveProbes = 9
# The number of milliseconds between keep-alive probes
keepaliveIntervalInMillis = 75
keepaliveIntervalInMillis = 75000

# HTTP configurations applicable with the upstream clusters
[router.upstream.httpConfigurations]
[router.upstream.hTTPConfigurations]
# Idle timeout in milliseconds for connections
idleTimeoutInMillis = 120000
# The maximum duration of a connection in milliseconds
maxConnectionDurationInMillis = 120000

# Timeouts managed by the connection manager
[router.connectionTimeout]
Expand Down

0 comments on commit ff3de82

Please sign in to comment.