From 604f259ea550fbcba9d679f91bae2ee7b109f12f Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Mon, 30 Aug 2021 18:42:31 -0700 Subject: [PATCH 1/8] all apis Signed-off-by: Jose Nino --- library/cc/engine_builder.cc | 18 +++++ library/cc/engine_builder.h | 6 ++ library/common/config/config.cc | 3 + .../engine/EnvoyConfiguration.java | 16 ++++- .../envoyproxy/envoymobile/EngineBuilder.kt | 49 ++++++++++++-- library/objective-c/EnvoyConfiguration.m | 9 +++ library/objective-c/EnvoyEngine.h | 6 ++ library/swift/EngineBuilder.swift | 39 +++++++++++ test/cc/unit/envoy_config_test.cc | 6 ++ .../engine/EnvoyConfigurationTest.kt | 11 +++- .../envoymobile/EngineBuilderTest.kt | 30 +++++++++ test/swift/EngineBuilderTests.swift | 66 +++++++++++++++++-- 12 files changed, 244 insertions(+), 15 deletions(-) diff --git a/library/cc/engine_builder.cc b/library/cc/engine_builder.cc index f18cae53af..9257d1362a 100644 --- a/library/cc/engine_builder.cc +++ b/library/cc/engine_builder.cc @@ -54,6 +54,21 @@ EngineBuilder::addDnsPreresolveHostnames(const std::string& dns_preresolve_hostn return *this; } +EngineBuilder& EngineBuilder::addH2ConnectionKeepaliveIntervalSeconds(int h2_connection_keepalive_interval_seconds) { + this->h2_connection_keepalive_interval_seconds_ = h2_connection_keepalive_interval_seconds; + return *this; +} + +EngineBuilder& EngineBuilder::addH2ConnectionKeepaliveIdleIntervalMilliseconds(int h2_connection_keepalive_idle_interval_milliseconds) { + this->h2_connection_keepalive_idle_interval_milliseconds_ = h2_connection_keepalive_idle_interval_milliseconds; + return *this; +} + +EngineBuilder& EngineBuilder::addH2ConnectionKeepaliveTimeoutSeconds(int h2_connection_keepalive_timeout_seconds) { + this->h2_connection_keepalive_timeout_seconds_ = h2_connection_keepalive_timeout_seconds; + return *this; +} + EngineBuilder& EngineBuilder::addStatsFlushSeconds(int stats_flush_seconds) { this->stats_flush_seconds_ = stats_flush_seconds; return *this; @@ -87,6 +102,9 @@ std::string EngineBuilder::generateConfigStr() { {"dns_preresolve_hostnames", this->dns_preresolve_hostnames_}, {"dns_refresh_rate", fmt::format("{}s", this->dns_refresh_seconds_)}, {"dns_query_timeout", fmt::format("{}s", this->dns_query_timeout_seconds_)}, + {"h2_connection_keepalive_interval", fmt::format("{}s", this->h2_connection_keepalive_interval_seconds_)}, + {"h2_connection_keepalive_idle_interval", fmt::format("{}s", this->h2_connection_keepalive_idle_interval_milliseconds_)}, + {"h2_connection_keepalive_timeout", fmt::format("{}s", this->h2_connection_keepalive_timeout_seconds_)}, { "metadata", fmt::format("{{ device_os: {}, app_version: {}, app_id: {} }}", this->device_os_, diff --git a/library/cc/engine_builder.h b/library/cc/engine_builder.h index f40546042c..b1d936fef9 100644 --- a/library/cc/engine_builder.h +++ b/library/cc/engine_builder.h @@ -24,6 +24,9 @@ class EngineBuilder { EngineBuilder& addDnsFailureRefreshSeconds(int base, int max); EngineBuilder& addDnsQueryTimeoutSeconds(int dns_query_timeout_seconds); EngineBuilder& addDnsPreresolveHostnames(const std::string& dns_preresolve_hostnames); + EngineBuilder& addH2ConnectionKeepaliveIntervalSeconds(int h2_connection_keepalive_interval_seconds); + EngineBuilder& addH2ConnectionKeepaliveIdleIntervalMilliseconds(int h2_connection_keepalive_idle_interval_milliseconds); + EngineBuilder& addh2ConnectionKeepaliveTimeoutSeconds(int h2_connection_keepalive_timeout_seconds); EngineBuilder& addStatsFlushSeconds(int stats_flush_seconds); EngineBuilder& addVirtualClusters(const std::string& virtual_clusters); EngineBuilder& setAppVersion(const std::string& app_version); @@ -53,6 +56,9 @@ class EngineBuilder { int dns_failure_refresh_seconds_max_ = 10; int dns_query_timeout_seconds_ = 25; std::string dns_preresolve_hostnames_ = "[]"; + int h2_connection_keepalive_interval_seconds = 2 + int h2_connection_keepalive_idle_interval_milliseconds = 1 + int h2_connection_keepalive_timeout_seconds = 5 int stats_flush_seconds_ = 60; std::string app_version_ = "unspecified"; std::string app_id_ = "unspecified"; diff --git a/library/common/config/config.cc b/library/common/config/config.cc index 76f9093cab..5a99558885 100644 --- a/library/common/config/config.cc +++ b/library/common/config/config.cc @@ -39,6 +39,9 @@ const std::string config_header = R"( - &dns_fail_max_interval 10s - &dns_query_timeout 25s - &dns_preresolve_hostnames [] +- &h2_connection_keepalive_interval 0s +- &h2_connection_keepalive_idle_interval 0s +- &h2_connection_keepalive_timeout 5s - &metadata {} - &stats_domain 127.0.0.1 - &stats_flush_interval 60s diff --git a/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java b/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java index 521e1302ee..f2cf970af6 100644 --- a/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java +++ b/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java @@ -20,6 +20,9 @@ public class EnvoyConfiguration { public final Integer dnsFailureRefreshSecondsMax; public final Integer dnsQueryTimeoutSeconds; public final String dnsPreresolveHostnames; + public final Integer h2ConnectionKeepaliveIntervalSeconds; + public final Integer h2ConnectionKeepaliveIdleIntervalMilliseconds; + public final Integer h2ConnectionKeepaliveTimeoutSeconds; public final List httpPlatformFilterFactories; public final Integer statsFlushSeconds; public final Integer streamIdleTimeoutSeconds; @@ -43,6 +46,9 @@ public class EnvoyConfiguration { * @param dnsFailureRefreshSecondsMax max rate in seconds to refresh DNS on failure. * @param dnsQueryTimeoutSeconds rate in seconds to timeout DNS queries. * @param dnsPreresolveHostnames hostnames to preresolve on Envoy Client construction. + * @param h2ConnectionKeepaliveIntervalSeconds rate in seconds to send h2 pings. + * @param h2ConnectionKeepaliveIdleIntervalMilliseconds rate in milliseconds seconds to send h2 pings on stream creation. + * @param h2ConnectionKeepaliveTimeoutSeconds rate in seconds to timeout h2 pings. * @param statsFlushSeconds interval at which to flush Envoy stats. * @param streamIdleTimeoutSeconds idle timeout for HTTP streams. * @param appVersion the App Version of the App using this Envoy Client. @@ -56,7 +62,9 @@ public EnvoyConfiguration(Boolean adminInterfaceEnabled, String grpcStatsDomain, @Nullable Integer statsdPort, int connectTimeoutSeconds, int dnsRefreshSeconds, int dnsFailureRefreshSecondsBase, int dnsFailureRefreshSecondsMax, int dnsQueryTimeoutSeconds, - String dnsPreresolveHostnames, int statsFlushSeconds, + String dnsPreresolveHostnames, int h2ConnectionKeepaliveIntervalSeconds, +int h2ConnectionKeepaliveIdleIntervalMilliseconds, +int h2ConnectionKeepaliveTimeoutSeconds, int statsFlushSeconds, int streamIdleTimeoutSeconds, String appVersion, String appId, String virtualClusters, List nativeFilterChain, List httpPlatformFilterFactories, @@ -70,6 +78,9 @@ public EnvoyConfiguration(Boolean adminInterfaceEnabled, String grpcStatsDomain, this.dnsFailureRefreshSecondsMax = dnsFailureRefreshSecondsMax; this.dnsQueryTimeoutSeconds = dnsQueryTimeoutSeconds; this.dnsPreresolveHostnames = dnsPreresolveHostnames; + this.h2ConnectionKeepaliveIntervalSeconds = h2ConnectionKeepaliveIntervalSeconds; +this.h2ConnectionKeepaliveIdleIntervalMilliseconds = h2ConnectionKeepaliveIdleIntervalMilliseconds; +this.h2ConnectionKeepaliveTimeoutSeconds = h2ConnectionKeepaliveTimeoutSeconds; this.statsFlushSeconds = statsFlushSeconds; this.streamIdleTimeoutSeconds = streamIdleTimeoutSeconds; this.appVersion = appVersion; @@ -118,6 +129,9 @@ String resolveTemplate(final String templateYAML, final String platformFilterTem .append(String.format("- &dns_fail_max_interval %ss\n", dnsFailureRefreshSecondsMax)) .append(String.format("- &dns_query_timeout %ss\n", dnsQueryTimeoutSeconds)) .append(String.format("- &dns_preresolve_hostnames %s\n", dnsPreresolveHostnames)) + .append(String.format("- &h2_connection_keepalive_interval %ss\n", h2ConnectionKeepaliveIntervalSeconds)) + .append(String.format("- &h2_connection_keepalive_idle_interval %sms\n", h2ConnectionKeepaliveIdleIntervalMilliseconds)) + .append(String.format("- &h2_connection_keepalive_timeout %ss\n", h2ConnectionKeepaliveTimeoutSeconds)) .append(String.format("- &stream_idle_timeout %ss\n", streamIdleTimeoutSeconds)) .append(String.format("- &metadata { device_os: %s, app_version: %s, app_id: %s }\n", "Android", appVersion, appId)) diff --git a/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt b/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt index ff2d9f9de8..6b84cc7345 100644 --- a/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt +++ b/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt @@ -35,6 +35,9 @@ open class EngineBuilder( private var dnsFailureRefreshSecondsMax = 10 private var dnsQueryTimeoutSeconds = 25 private var dnsPreresolveHostnames = "[]" + private var h2ConnectionKeepaliveIntervalSeconds = 2 + private var h2ConnectionKeepaliveIdleIntervalMilliseconds = 1 + private var h2ConnectionKeepaliveTimeoutSeconds = 5 private var statsFlushSeconds = 60 private var streamIdleTimeoutSeconds = 15 private var appVersion = "unspecified" @@ -148,6 +151,42 @@ open class EngineBuilder( return this } + /** + * Add a rate at which to ping h2 connections. + * + * @param h2ConnectionKeepaliveIntervalSeconds rate in seconds to ping h2 connections. + * + * @return this builder. + */ + fun addH2ConnectionKeepaliveIntervalSeconds(h2ConnectionKeepaliveIntervalSeconds: Int): EngineBuilder { + this.h2ConnectionKeepaliveIntervalSeconds = h2ConnectionKeepaliveIntervalSeconds + return this + } + + /** + * Add a rate at which to ping h2 connections on new stream creation if the connection has sat idle. + * + * @param h2ConnectionKeepaliveIdleIntervalMilliseconds rate in milliseconds. + * + * @return this builder. + */ + fun addH2ConnectionKeepaliveIdleIntervalMilliseconds(h2ConnectionKeepaliveIdleIntervalMilliseconds: Int): EngineBuilder { + this.h2ConnectionKeepaliveIdleIntervalMilliseconds = h2ConnectionKeepaliveIdleIntervalMilliseconds + return this + } + + /** + * Add a rate at which to timeout h2 pings. + * + * @param h2ConnectionKeepaliveTimeoutSeconds rate in seconds to timeout h2 pings. + * + * @return this builder. + */ + fun addH2ConnectionKeepaliveTimeoutSeconds(h2ConnectionKeepaliveTimeoutSeconds: Int): EngineBuilder { + this.h2ConnectionKeepaliveTimeoutSeconds = h2ConnectionKeepaliveTimeoutSeconds + return this + } + /** * Add an interval at which to flush Envoy stats. * @@ -321,8 +360,9 @@ open class EngineBuilder( EnvoyConfiguration( adminInterfaceEnabled, grpcStatsDomain, statsDPort, connectTimeoutSeconds, dnsRefreshSeconds, dnsFailureRefreshSecondsBase, dnsFailureRefreshSecondsMax, - dnsQueryTimeoutSeconds, - dnsPreresolveHostnames, statsFlushSeconds, streamIdleTimeoutSeconds, appVersion, appId, + dnsQueryTimeoutSeconds, dnsPreresolveHostnames, h2ConnectionKeepaliveIntervalSeconds, + h2ConnectionKeepaliveIdleIntervalMilliseconds, h2ConnectionKeepaliveTimeoutSeconds, + statsFlushSeconds, streamIdleTimeoutSeconds, appVersion, appId, virtualClusters, nativeFilterChain, platformFilterChain, stringAccessors ), configuration.yaml, @@ -335,8 +375,9 @@ open class EngineBuilder( EnvoyConfiguration( adminInterfaceEnabled, grpcStatsDomain, statsDPort, connectTimeoutSeconds, dnsRefreshSeconds, dnsFailureRefreshSecondsBase, dnsFailureRefreshSecondsMax, - dnsQueryTimeoutSeconds, - dnsPreresolveHostnames, statsFlushSeconds, streamIdleTimeoutSeconds, appVersion, appId, + dnsQueryTimeoutSeconds, dnsPreresolveHostnames, h2ConnectionKeepaliveIntervalSeconds, + h2ConnectionKeepaliveIdleIntervalMilliseconds, h2ConnectionKeepaliveTimeoutSeconds, + statsFlushSeconds, streamIdleTimeoutSeconds, appVersion, appId, virtualClusters, nativeFilterChain, platformFilterChain, stringAccessors ), logLevel diff --git a/library/objective-c/EnvoyConfiguration.m b/library/objective-c/EnvoyConfiguration.m index a1fc3199b4..5d585d58dc 100644 --- a/library/objective-c/EnvoyConfiguration.m +++ b/library/objective-c/EnvoyConfiguration.m @@ -13,6 +13,9 @@ @implementation EnvoyConfiguration dnsFailureRefreshSecondsMax:(UInt32)dnsFailureRefreshSecondsMax dnsQueryTimeoutSeconds:(UInt32)dnsQueryTimeoutSeconds dnsPreresolveHostnames:(NSString *)dnsPreresolveHostnames + h2ConnectionKeepaliveIntervalSeconds:(UInt32)h2ConnectionKeepaliveIntervalSeconds + h2ConnectionKeepaliveIdleIntervalMilliseconds:(UInt32)h2ConnectionKeepaliveIdleIntervalMilliseconds + h2ConnectionKeepaliveTimeoutSeconds:(UInt32)h2ConnectionKeepaliveTimeoutSeconds statsFlushSeconds:(UInt32)statsFlushSeconds streamIdleTimeoutSeconds:(UInt32)streamIdleTimeoutSeconds appVersion:(NSString *)appVersion @@ -37,6 +40,9 @@ @implementation EnvoyConfiguration self.dnsFailureRefreshSecondsMax = dnsFailureRefreshSecondsMax; self.dnsQueryTimeoutSeconds = dnsQueryTimeoutSeconds; self.dnsPreresolveHostnames = dnsPreresolveHostnames; + self.h2ConnectionKeepaliveIntervalSeconds = h2ConnectionKeepaliveIntervalSeconds; + self.h2ConnectionKeepaliveIdleIntervalMilliseconds = h2ConnectionKeepaliveIdleIntervalMilliseconds; + self.h2ConnectionKeepaliveTimeoutSeconds = h2ConnectionKeepaliveTimeoutSeconds; self.statsFlushSeconds = statsFlushSeconds; self.streamIdleTimeoutSeconds = streamIdleTimeoutSeconds; self.appVersion = appVersion; @@ -108,6 +114,9 @@ - (nullable NSString *)resolveTemplate:(NSString *)templateYAML { [definitions appendFormat:@"- &dns_query_timeout %lus\n", (unsigned long)self.dnsQueryTimeoutSeconds]; [definitions appendFormat:@"- &dns_preresolve_hostnames %@\n", self.dnsPreresolveHostnames]; + [definitions appendFormat:@"- &h2_connection_keepalive_interval %lus\n", (unsigned long)self.h2ConnectionKeepaliveIntervalSeconds]; + [definitions appendFormat:@"- &h2_connection_keepalive_idle_interval %lums\n", (unsigned long)self.h2ConnectionKeepaliveIdleIntervalMilliseconds]; + [definitions appendFormat:@"- &h2_connection_keepalive_timeout %lus\n", (unsigned long)self.h2ConnectionKeepaliveTimeoutSeconds]; [definitions appendFormat:@"- &stream_idle_timeout %lus\n", (unsigned long)self.streamIdleTimeoutSeconds]; [definitions appendFormat:@"- &metadata { device_os: %@, app_version: %@, app_id: %@ }\n", @"iOS", diff --git a/library/objective-c/EnvoyEngine.h b/library/objective-c/EnvoyEngine.h index 876aa38786..4694618950 100644 --- a/library/objective-c/EnvoyEngine.h +++ b/library/objective-c/EnvoyEngine.h @@ -301,6 +301,9 @@ extern const int kEnvoyFilterResumeStatusResumeIteration; @property (nonatomic, assign) UInt32 dnsFailureRefreshSecondsMax; @property (nonatomic, assign) UInt32 dnsQueryTimeoutSeconds; @property (nonatomic, strong) NSString *dnsPreresolveHostnames; +@property (nonatomic, assign) UInt32 h2ConnectionKeepaliveIntervalSeconds; +@property (nonatomic, assign) UInt32 h2ConnectionKeepaliveIdleIntervalMilliseconds; +@property (nonatomic, assign) UInt32 h2ConnectionKeepaliveTimeoutSeconds; @property (nonatomic, assign) UInt32 statsFlushSeconds; @property (nonatomic, assign) UInt32 streamIdleTimeoutSeconds; @property (nonatomic, strong) NSString *appVersion; @@ -324,6 +327,9 @@ extern const int kEnvoyFilterResumeStatusResumeIteration; dnsFailureRefreshSecondsMax:(UInt32)dnsFailureRefreshSecondsMax dnsQueryTimeoutSeconds:(UInt32)dnsQueryTimeoutSeconds dnsPreresolveHostnames:(NSString *)dnsPreresolveHostnames + h2ConnectionKeepaliveIntervalSeconds:(UInt32)h2ConnectionKeepaliveIntervalSeconds + h2ConnectionKeepaliveIdleIntervalMilliseconds:(UInt32)h2ConnectionKeepaliveIdleIntervalMilliseconds + h2ConnectionKeepaliveTimeoutSeconds:(UInt32)h2ConnectionKeepaliveTimeoutSeconds statsFlushSeconds:(UInt32)statsFlushSeconds streamIdleTimeoutSeconds:(UInt32)streamIdleTimeoutSeconds appVersion:(NSString *)appVersion diff --git a/library/swift/EngineBuilder.swift b/library/swift/EngineBuilder.swift index f33fbd0aa2..1997be4b13 100644 --- a/library/swift/EngineBuilder.swift +++ b/library/swift/EngineBuilder.swift @@ -21,6 +21,9 @@ open class EngineBuilder: NSObject { private var dnsFailureRefreshSecondsMax: UInt32 = 10 private var dnsQueryTimeoutSeconds: UInt32 = 25 private var dnsPreresolveHostnames: String = "[]" + private var h2ConnectionKeepaliveIntervalSeconds: UInt32 = 2 + private var h2ConnectionKeepaliveIdleIntervalMilliseconds: UInt32 = 1 + private var h2ConnectionKeepaliveTimeoutSeconds: UInt32 = 5 private var statsFlushSeconds: UInt32 = 60 private var streamIdleTimeoutSeconds: UInt32 = 15 private var appVersion: String = "unspecified" @@ -130,6 +133,39 @@ open class EngineBuilder: NSObject { return self } + /// Add a rate at which to ping h2 connections. + /// + /// - parameter h2ConnectionKeepaliveIntervalSeconds: Rate in seconds to ping h2 connections. + /// + /// - returns: This builder. + @discardableResult + public func addH2ConnectionKeepaliveIntervalSeconds(_ h2ConnectionKeepaliveIntervalSeconds: UInt32) -> Self { + self.h2ConnectionKeepaliveIntervalSeconds = h2ConnectionKeepaliveIntervalSeconds + return self + } + + /// Add a rate at which to ping h2 connections on new stream creation if the connection has sat idle. + /// + /// - parameter h2ConnectionKeepaliveIdleIntervalMilliseconds: Rate in milliseconds. + /// + /// - returns: This builder. + @discardableResult + public func addH2ConnectionKeepaliveIdleIntervalMilliseconds(_ h2ConnectionKeepaliveIdleIntervalMilliseconds: UInt32) -> Self { + self.h2ConnectionKeepaliveIdleIntervalMilliseconds = h2ConnectionKeepaliveIdleIntervalMilliseconds + return self + } + + /// Add a rate at which to timeout h2 pings. + /// + /// - parameter h2ConnectionKeepaliveTimeoutSeconds: Rate in seconds to timeout h2 pings. + /// + /// - returns: This builder. + @discardableResult + public func addH2ConnectionKeepaliveTimeoutSeconds(_ h2ConnectionKeepaliveTimeoutSeconds: UInt32) -> Self { + self.h2ConnectionKeepaliveTimeoutSeconds = h2ConnectionKeepaliveTimeoutSeconds + return self + } + /// Add an interval at which to flush Envoy stats. /// /// - parameter statsFlushSeconds: Interval at which to flush Envoy stats. @@ -299,6 +335,9 @@ open class EngineBuilder: NSObject { dnsFailureRefreshSecondsMax: self.dnsFailureRefreshSecondsMax, dnsQueryTimeoutSeconds: self.dnsQueryTimeoutSeconds, dnsPreresolveHostnames: self.dnsPreresolveHostnames, + h2ConnectionKeepaliveIntervalSeconds: self.h2ConnectionKeepaliveIntervalSeconds, + h2ConnectionKeepaliveIdleIntervalMilliseconds: self.h2ConnectionKeepaliveIdleIntervalMilliseconds, + h2ConnectionKeepaliveTimeoutSeconds: self.h2ConnectionKeepaliveTimeoutSeconds, statsFlushSeconds: self.statsFlushSeconds, streamIdleTimeoutSeconds: self.streamIdleTimeoutSeconds, appVersion: self.appVersion, diff --git a/test/cc/unit/envoy_config_test.cc b/test/cc/unit/envoy_config_test.cc index 6b4cd8b419..d6f45f8a7c 100644 --- a/test/cc/unit/envoy_config_test.cc +++ b/test/cc/unit/envoy_config_test.cc @@ -19,6 +19,9 @@ TEST(TestConfig, ConfigIsApplied) { .addDnsFailureRefreshSeconds(789, 987) .addDnsQueryTimeoutSeconds(321) .addDnsPreresolveHostnames("[hostname]") + .addH2ConnectionKeepaliveIntervalSeconds(111) + .addH2ConnectionKeepaliveIdleIntervalMilliseconds(222) + .addH2ConnectionKeepaliveTimeoutSeconds(333) .addStatsFlushSeconds(654) .addVirtualClusters("[virtual-clusters]") .setAppVersion("1.2.3") @@ -34,6 +37,9 @@ TEST(TestConfig, ConfigIsApplied) { "- &dns_fail_max_interval 987s", "- &dns_query_timeout 321s", "- &dns_preresolve_hostnames [hostname]", + "- &h2_connection_keepalive_interval 111s" + "- &h2_connection_keepalive_idle_interval 222ms" + "- &h2_connection_keepalive_timeout 333s" "- &stats_flush_interval 654s", "- &virtual_clusters [virtual-clusters]", ("- &metadata { device_os: probably-ubuntu-on-CI, " diff --git a/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt b/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt index 77140f393c..80223857ae 100644 --- a/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt +++ b/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt @@ -28,7 +28,7 @@ class EnvoyConfigurationTest { @Test fun `resolving with default configuration resolves with values`() { val envoyConfiguration = EnvoyConfiguration( - false, "stats.foo.com", null, 123, 234, 345, 456, 321, "[hostname]", 567, 678, "v1.2.3", "com.mydomain.myapp", "[test]", + false, "stats.foo.com", null, 123, 234, 345, 456, 321, "[hostname]", 111, 222, 333, 567, 678, "v1.2.3", "com.mydomain.myapp", "[test]", listOf(EnvoyNativeFilterConfig("filter_name", "test_config")), emptyList(), emptyMap() ) @@ -47,6 +47,11 @@ class EnvoyConfigurationTest { assertThat(resolvedTemplate).contains("&dns_query_timeout 321s") assertThat(resolvedTemplate).contains("&dns_preresolve_hostnames [hostname]") + // H2 Ping + assertThat(resolvedTemplate).contains("&h2_connection_keepalive_interval 111s") + assertThat(resolvedTemplate).contains("&h2_connection_keepalive_idle_interval 222ms") + assertThat(resolvedTemplate).contains("&h2_connection_keepalive_timeout 333s") + // Metadata assertThat(resolvedTemplate).contains("os: Android") assertThat(resolvedTemplate).contains("app_version: v1.2.3") @@ -66,7 +71,7 @@ class EnvoyConfigurationTest { @Test fun `resolve templates with invalid templates will throw on build`() { val envoyConfiguration = EnvoyConfiguration( - false, "stats.foo.com", null, 123, 234, 345, 456, 321, "[hostname]", 567, 678, "v1.2.3", "com.mydomain.myapp", "[test]", + false, "stats.foo.com", null, 123, 234, 345, 456, 321, "[hostname]", 123, 123, 123, 567, 678, "v1.2.3", "com.mydomain.myapp", "[test]", emptyList(), emptyList(), emptyMap() ) @@ -81,7 +86,7 @@ class EnvoyConfigurationTest { @Test fun `cannot configure both statsD and gRPC stat sink`() { val envoyConfiguration = EnvoyConfiguration( - false, "stats.foo.com", 5050, 123, 234, 345, 456, 321, "[hostname]", 567, 678, "v1.2.3", "com.mydomain.myapp", "[test]", + false, "stats.foo.com", 5050, 123, 234, 345, 456, 321, "[hostname]", 123, 123, 123, 567, 678, "v1.2.3", "com.mydomain.myapp", "[test]", emptyList(), emptyList(), emptyMap() ) diff --git a/test/kotlin/io/envoyproxy/envoymobile/EngineBuilderTest.kt b/test/kotlin/io/envoyproxy/envoymobile/EngineBuilderTest.kt index b6b3e5e681..d7ea52f957 100644 --- a/test/kotlin/io/envoyproxy/envoymobile/EngineBuilderTest.kt +++ b/test/kotlin/io/envoyproxy/envoymobile/EngineBuilderTest.kt @@ -80,6 +80,36 @@ class EngineBuilderTest { assertThat(engine.envoyConfiguration!!.dnsQueryTimeoutSeconds).isEqualTo(1234) } + @Test + fun `specifying H2 Ping interval overrides default`() { + engineBuilder = EngineBuilder(Standard()) + engineBuilder.addEngineType { envoyEngine } + engineBuilder.addH2ConnectionKeepaliveIntervalSeconds(111) + + val engine = engineBuilder.build() as EngineImpl + assertThat(engine.envoyConfiguration!!.h2ConnectionKeepaliveIntervalSeconds).isEqualTo(111) + } + + @Test + fun `specifying H2 Ping idle interval overrides default`() { + engineBuilder = EngineBuilder(Standard()) + engineBuilder.addEngineType { envoyEngine } + engineBuilder.addH2ConnectionKeepaliveIdleIntervalMilliseconds(1234) + + val engine = engineBuilder.build() as EngineImpl + assertThat(engine.envoyConfiguration!!.h2ConnectionKeepaliveIdleIntervalMilliseconds).isEqualTo(1234) + } + + @Test + fun `specifying H2 Ping timeout overrides default`() { + engineBuilder = EngineBuilder(Standard()) + engineBuilder.addEngineType { envoyEngine } + engineBuilder.addH2ConnectionKeepaliveTimeoutSeconds(1234) + + val engine = engineBuilder.build() as EngineImpl + assertThat(engine.envoyConfiguration!!.h2ConnectionKeepaliveTimeoutSeconds).isEqualTo(1234) + } + @Test fun `specifying stats flush overrides default`() { engineBuilder = EngineBuilder(Standard()) diff --git a/test/swift/EngineBuilderTests.swift b/test/swift/EngineBuilderTests.swift index f74f40e510..99be585881 100644 --- a/test/swift/EngineBuilderTests.swift +++ b/test/swift/EngineBuilderTests.swift @@ -137,31 +137,73 @@ final class EngineBuilderTests: XCTestCase { self.waitForExpectations(timeout: 0.01) } - func testAddingPlatformFiltersToConfigurationWhenRunningEnvoy() { + func testAddingDNSFailureRefreshSecondsAddsToConfigurationWhenRunningEnvoy() { let expectation = self.expectation(description: "Run called with expected data") MockEnvoyEngine.onRunWithConfig = { config, _ in - XCTAssertEqual(1, config.httpPlatformFilterFactories.count) + XCTAssertEqual(1234, config.dnsFailureRefreshSecondsBase) + XCTAssertEqual(5678, config.dnsFailureRefreshSecondsMax) expectation.fulfill() } _ = EngineBuilder() .addEngineType(MockEnvoyEngine.self) - .addPlatformFilter(TestFilter.init) + .addDNSFailureRefreshSeconds(base: 1234, max: 5678) .build() self.waitForExpectations(timeout: 0.01) } - func testAddingDNSFailureRefreshSecondsAddsToConfigurationWhenRunningEnvoy() { + func testAddingH2ConnectionKeepaliveIntervalSecondsAddsToConfigurationWhenRunningEnvoy() { let expectation = self.expectation(description: "Run called with expected data") MockEnvoyEngine.onRunWithConfig = { config, _ in - XCTAssertEqual(1234, config.dnsFailureRefreshSecondsBase) - XCTAssertEqual(5678, config.dnsFailureRefreshSecondsMax) + XCTAssertEqual(234, config.h2ConnectionKeepaliveIntervalSeconds) expectation.fulfill() } _ = EngineBuilder() .addEngineType(MockEnvoyEngine.self) - .addDNSFailureRefreshSeconds(base: 1234, max: 5678) + .addH2ConnectionKeepaliveIntervalSeconds(234) + .build() + self.waitForExpectations(timeout: 0.01) + } + + func testAddingH2ConnectionKeepaliveIdleIntervalMillisecondsAddsToConfigurationWhenRunningEnvoy() { + let expectation = self.expectation(description: "Run called with expected data") + MockEnvoyEngine.onRunWithConfig = { config, _ in + XCTAssertEqual(234, config.h2ConnectionKeepaliveIdleIntervalMilliseconds) + expectation.fulfill() + } + + _ = EngineBuilder() + .addEngineType(MockEnvoyEngine.self) + .addH2ConnectionKeepaliveIdleIntervalMilliseconds(234) + .build() + self.waitForExpectations(timeout: 0.01) + } + + func testAddingH2ConnectionKeepaliveTimeoutSecondsAddsToConfigurationWhenRunningEnvoy() { + let expectation = self.expectation(description: "Run called with expected data") + MockEnvoyEngine.onRunWithConfig = { config, _ in + XCTAssertEqual(234, config.h2ConnectionKeepaliveTimeoutSeconds) + expectation.fulfill() + } + + _ = EngineBuilder() + .addEngineType(MockEnvoyEngine.self) + .addH2ConnectionKeepaliveTimeoutSeconds(234) + .build() + self.waitForExpectations(timeout: 0.01) + } + + func testAddingPlatformFiltersToConfigurationWhenRunningEnvoy() { + let expectation = self.expectation(description: "Run called with expected data") + MockEnvoyEngine.onRunWithConfig = { config, _ in + XCTAssertEqual(1, config.httpPlatformFilterFactories.count) + expectation.fulfill() + } + + _ = EngineBuilder() + .addEngineType(MockEnvoyEngine.self) + .addPlatformFilter(TestFilter.init) .build() self.waitForExpectations(timeout: 0.01) } @@ -274,6 +316,9 @@ final class EngineBuilderTests: XCTestCase { dnsFailureRefreshSecondsMax: 500, dnsQueryTimeoutSeconds: 800, dnsPreresolveHostnames: "[test]", + h2ConnectionKeepaliveIntervalSeconds: 111, + h2ConnectionKeepaliveIdleIntervalMilliseconds: 222, + h2ConnectionKeepaliveTimeoutSeconds: 333, statsFlushSeconds: 600, streamIdleTimeoutSeconds: 700, appVersion: "v1.2.3", @@ -297,6 +342,10 @@ final class EngineBuilderTests: XCTestCase { XCTAssertTrue(resolvedYAML.contains("&dns_query_timeout 800s")) XCTAssertTrue(resolvedYAML.contains("&dns_preresolve_hostnames [test]")) + XCTAssertTrue(resolvedYAML.contains("&h2_connection_keepalive_interval 111s")) + XCTAssertTrue(resolvedYAML.contains("&h2_connection_keepalive_idle_interval 222ms")) + XCTAssertTrue(resolvedYAML.contains("&h2_connection_keepalive_timeout 333s")) + XCTAssertTrue(resolvedYAML.contains("&stream_idle_timeout 700s")) XCTAssertFalse(resolvedYAML.contains("admin: *admin_interface")) @@ -328,6 +377,9 @@ final class EngineBuilderTests: XCTestCase { dnsFailureRefreshSecondsMax: 500, dnsQueryTimeoutSeconds: 800, dnsPreresolveHostnames: "[test]", + h2ConnectionKeepaliveIntervalSeconds: 111, + h2ConnectionKeepaliveIdleIntervalMilliseconds: 222, + h2ConnectionKeepaliveTimeoutSeconds: 333, statsFlushSeconds: 600, streamIdleTimeoutSeconds: 700, appVersion: "v1.2.3", From 9fe0615f3bd21f29fd399ebdd1b121d1c11d5f56 Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Mon, 30 Aug 2021 18:45:05 -0700 Subject: [PATCH 2/8] fmt Signed-off-by: Jose Nino --- library/cc/engine_builder.cc | 21 ++++--- library/cc/engine_builder.h | 16 ++--- .../engine/EnvoyConfiguration.java | 21 ++++--- library/objective-c/EnvoyConfiguration.m | 61 +++++++++++-------- library/objective-c/EnvoyEngine.h | 49 ++++++++------- library/swift/EngineBuilder.swift | 21 ++++--- test/swift/EngineBuilderTests.swift | 2 +- 7 files changed, 111 insertions(+), 80 deletions(-) diff --git a/library/cc/engine_builder.cc b/library/cc/engine_builder.cc index 9257d1362a..4b68b37bdb 100644 --- a/library/cc/engine_builder.cc +++ b/library/cc/engine_builder.cc @@ -54,17 +54,21 @@ EngineBuilder::addDnsPreresolveHostnames(const std::string& dns_preresolve_hostn return *this; } -EngineBuilder& EngineBuilder::addH2ConnectionKeepaliveIntervalSeconds(int h2_connection_keepalive_interval_seconds) { +EngineBuilder& EngineBuilder::addH2ConnectionKeepaliveIntervalSeconds( + int h2_connection_keepalive_interval_seconds) { this->h2_connection_keepalive_interval_seconds_ = h2_connection_keepalive_interval_seconds; return *this; } -EngineBuilder& EngineBuilder::addH2ConnectionKeepaliveIdleIntervalMilliseconds(int h2_connection_keepalive_idle_interval_milliseconds) { - this->h2_connection_keepalive_idle_interval_milliseconds_ = h2_connection_keepalive_idle_interval_milliseconds; +EngineBuilder& EngineBuilder::addH2ConnectionKeepaliveIdleIntervalMilliseconds( + int h2_connection_keepalive_idle_interval_milliseconds) { + this->h2_connection_keepalive_idle_interval_milliseconds_ = + h2_connection_keepalive_idle_interval_milliseconds; return *this; } -EngineBuilder& EngineBuilder::addH2ConnectionKeepaliveTimeoutSeconds(int h2_connection_keepalive_timeout_seconds) { +EngineBuilder& +EngineBuilder::addH2ConnectionKeepaliveTimeoutSeconds(int h2_connection_keepalive_timeout_seconds) { this->h2_connection_keepalive_timeout_seconds_ = h2_connection_keepalive_timeout_seconds; return *this; } @@ -102,9 +106,12 @@ std::string EngineBuilder::generateConfigStr() { {"dns_preresolve_hostnames", this->dns_preresolve_hostnames_}, {"dns_refresh_rate", fmt::format("{}s", this->dns_refresh_seconds_)}, {"dns_query_timeout", fmt::format("{}s", this->dns_query_timeout_seconds_)}, - {"h2_connection_keepalive_interval", fmt::format("{}s", this->h2_connection_keepalive_interval_seconds_)}, - {"h2_connection_keepalive_idle_interval", fmt::format("{}s", this->h2_connection_keepalive_idle_interval_milliseconds_)}, - {"h2_connection_keepalive_timeout", fmt::format("{}s", this->h2_connection_keepalive_timeout_seconds_)}, + {"h2_connection_keepalive_interval", + fmt::format("{}s", this->h2_connection_keepalive_interval_seconds_)}, + {"h2_connection_keepalive_idle_interval", + fmt::format("{}s", this->h2_connection_keepalive_idle_interval_milliseconds_)}, + {"h2_connection_keepalive_timeout", + fmt::format("{}s", this->h2_connection_keepalive_timeout_seconds_)}, { "metadata", fmt::format("{{ device_os: {}, app_version: {}, app_id: {} }}", this->device_os_, diff --git a/library/cc/engine_builder.h b/library/cc/engine_builder.h index b1d936fef9..e4efadf982 100644 --- a/library/cc/engine_builder.h +++ b/library/cc/engine_builder.h @@ -24,9 +24,12 @@ class EngineBuilder { EngineBuilder& addDnsFailureRefreshSeconds(int base, int max); EngineBuilder& addDnsQueryTimeoutSeconds(int dns_query_timeout_seconds); EngineBuilder& addDnsPreresolveHostnames(const std::string& dns_preresolve_hostnames); - EngineBuilder& addH2ConnectionKeepaliveIntervalSeconds(int h2_connection_keepalive_interval_seconds); - EngineBuilder& addH2ConnectionKeepaliveIdleIntervalMilliseconds(int h2_connection_keepalive_idle_interval_milliseconds); - EngineBuilder& addh2ConnectionKeepaliveTimeoutSeconds(int h2_connection_keepalive_timeout_seconds); + EngineBuilder& + addH2ConnectionKeepaliveIntervalSeconds(int h2_connection_keepalive_interval_seconds); + EngineBuilder& addH2ConnectionKeepaliveIdleIntervalMilliseconds( + int h2_connection_keepalive_idle_interval_milliseconds); + EngineBuilder& + addh2ConnectionKeepaliveTimeoutSeconds(int h2_connection_keepalive_timeout_seconds); EngineBuilder& addStatsFlushSeconds(int stats_flush_seconds); EngineBuilder& addVirtualClusters(const std::string& virtual_clusters); EngineBuilder& setAppVersion(const std::string& app_version); @@ -56,10 +59,9 @@ class EngineBuilder { int dns_failure_refresh_seconds_max_ = 10; int dns_query_timeout_seconds_ = 25; std::string dns_preresolve_hostnames_ = "[]"; - int h2_connection_keepalive_interval_seconds = 2 - int h2_connection_keepalive_idle_interval_milliseconds = 1 - int h2_connection_keepalive_timeout_seconds = 5 - int stats_flush_seconds_ = 60; + int h2_connection_keepalive_interval_seconds = + 2 int h2_connection_keepalive_idle_interval_milliseconds = + 1 int h2_connection_keepalive_timeout_seconds = 5 int stats_flush_seconds_ = 60; std::string app_version_ = "unspecified"; std::string app_id_ = "unspecified"; std::string device_os_ = "unspecified"; diff --git a/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java b/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java index f2cf970af6..0b1a4711db 100644 --- a/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java +++ b/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java @@ -47,7 +47,8 @@ public class EnvoyConfiguration { * @param dnsQueryTimeoutSeconds rate in seconds to timeout DNS queries. * @param dnsPreresolveHostnames hostnames to preresolve on Envoy Client construction. * @param h2ConnectionKeepaliveIntervalSeconds rate in seconds to send h2 pings. - * @param h2ConnectionKeepaliveIdleIntervalMilliseconds rate in milliseconds seconds to send h2 pings on stream creation. + * @param h2ConnectionKeepaliveIdleIntervalMilliseconds rate in milliseconds seconds to send h2 + * pings on stream creation. * @param h2ConnectionKeepaliveTimeoutSeconds rate in seconds to timeout h2 pings. * @param statsFlushSeconds interval at which to flush Envoy stats. * @param streamIdleTimeoutSeconds idle timeout for HTTP streams. @@ -63,8 +64,8 @@ public EnvoyConfiguration(Boolean adminInterfaceEnabled, String grpcStatsDomain, int dnsRefreshSeconds, int dnsFailureRefreshSecondsBase, int dnsFailureRefreshSecondsMax, int dnsQueryTimeoutSeconds, String dnsPreresolveHostnames, int h2ConnectionKeepaliveIntervalSeconds, -int h2ConnectionKeepaliveIdleIntervalMilliseconds, -int h2ConnectionKeepaliveTimeoutSeconds, int statsFlushSeconds, + int h2ConnectionKeepaliveIdleIntervalMilliseconds, + int h2ConnectionKeepaliveTimeoutSeconds, int statsFlushSeconds, int streamIdleTimeoutSeconds, String appVersion, String appId, String virtualClusters, List nativeFilterChain, List httpPlatformFilterFactories, @@ -79,8 +80,9 @@ public EnvoyConfiguration(Boolean adminInterfaceEnabled, String grpcStatsDomain, this.dnsQueryTimeoutSeconds = dnsQueryTimeoutSeconds; this.dnsPreresolveHostnames = dnsPreresolveHostnames; this.h2ConnectionKeepaliveIntervalSeconds = h2ConnectionKeepaliveIntervalSeconds; -this.h2ConnectionKeepaliveIdleIntervalMilliseconds = h2ConnectionKeepaliveIdleIntervalMilliseconds; -this.h2ConnectionKeepaliveTimeoutSeconds = h2ConnectionKeepaliveTimeoutSeconds; + this.h2ConnectionKeepaliveIdleIntervalMilliseconds = + h2ConnectionKeepaliveIdleIntervalMilliseconds; + this.h2ConnectionKeepaliveTimeoutSeconds = h2ConnectionKeepaliveTimeoutSeconds; this.statsFlushSeconds = statsFlushSeconds; this.streamIdleTimeoutSeconds = streamIdleTimeoutSeconds; this.appVersion = appVersion; @@ -129,9 +131,12 @@ String resolveTemplate(final String templateYAML, final String platformFilterTem .append(String.format("- &dns_fail_max_interval %ss\n", dnsFailureRefreshSecondsMax)) .append(String.format("- &dns_query_timeout %ss\n", dnsQueryTimeoutSeconds)) .append(String.format("- &dns_preresolve_hostnames %s\n", dnsPreresolveHostnames)) - .append(String.format("- &h2_connection_keepalive_interval %ss\n", h2ConnectionKeepaliveIntervalSeconds)) - .append(String.format("- &h2_connection_keepalive_idle_interval %sms\n", h2ConnectionKeepaliveIdleIntervalMilliseconds)) - .append(String.format("- &h2_connection_keepalive_timeout %ss\n", h2ConnectionKeepaliveTimeoutSeconds)) + .append(String.format("- &h2_connection_keepalive_interval %ss\n", + h2ConnectionKeepaliveIntervalSeconds)) + .append(String.format("- &h2_connection_keepalive_idle_interval %sms\n", + h2ConnectionKeepaliveIdleIntervalMilliseconds)) + .append(String.format("- &h2_connection_keepalive_timeout %ss\n", + h2ConnectionKeepaliveTimeoutSeconds)) .append(String.format("- &stream_idle_timeout %ss\n", streamIdleTimeoutSeconds)) .append(String.format("- &metadata { device_os: %s, app_version: %s, app_id: %s }\n", "Android", appVersion, appId)) diff --git a/library/objective-c/EnvoyConfiguration.m b/library/objective-c/EnvoyConfiguration.m index 5d585d58dc..257a41560f 100644 --- a/library/objective-c/EnvoyConfiguration.m +++ b/library/objective-c/EnvoyConfiguration.m @@ -4,29 +4,32 @@ @implementation EnvoyConfiguration -- (instancetype) - initWithAdminInterfaceEnabled:(BOOL)adminInterfaceEnabled - GrpcStatsDomain:(nullable NSString *)grpcStatsDomain - connectTimeoutSeconds:(UInt32)connectTimeoutSeconds - dnsRefreshSeconds:(UInt32)dnsRefreshSeconds - dnsFailureRefreshSecondsBase:(UInt32)dnsFailureRefreshSecondsBase - dnsFailureRefreshSecondsMax:(UInt32)dnsFailureRefreshSecondsMax - dnsQueryTimeoutSeconds:(UInt32)dnsQueryTimeoutSeconds - dnsPreresolveHostnames:(NSString *)dnsPreresolveHostnames - h2ConnectionKeepaliveIntervalSeconds:(UInt32)h2ConnectionKeepaliveIntervalSeconds - h2ConnectionKeepaliveIdleIntervalMilliseconds:(UInt32)h2ConnectionKeepaliveIdleIntervalMilliseconds - h2ConnectionKeepaliveTimeoutSeconds:(UInt32)h2ConnectionKeepaliveTimeoutSeconds - statsFlushSeconds:(UInt32)statsFlushSeconds - streamIdleTimeoutSeconds:(UInt32)streamIdleTimeoutSeconds - appVersion:(NSString *)appVersion - appId:(NSString *)appId - virtualClusters:(NSString *)virtualClusters - directResponseMatchers:(NSString *)directResponseMatchers - directResponses:(NSString *)directResponses - nativeFilterChain:(NSArray *)nativeFilterChain - platformFilterChain:(NSArray *)httpPlatformFilterFactories - stringAccessors: - (NSDictionary *)stringAccessors { +- (instancetype)initWithAdminInterfaceEnabled:(BOOL)adminInterfaceEnabled + GrpcStatsDomain:(nullable NSString *)grpcStatsDomain + connectTimeoutSeconds:(UInt32)connectTimeoutSeconds + dnsRefreshSeconds:(UInt32)dnsRefreshSeconds + dnsFailureRefreshSecondsBase:(UInt32)dnsFailureRefreshSecondsBase + dnsFailureRefreshSecondsMax:(UInt32)dnsFailureRefreshSecondsMax + dnsQueryTimeoutSeconds:(UInt32)dnsQueryTimeoutSeconds + dnsPreresolveHostnames:(NSString *)dnsPreresolveHostnames + h2ConnectionKeepaliveIntervalSeconds:(UInt32)h2ConnectionKeepaliveIntervalSeconds + h2ConnectionKeepaliveIdleIntervalMilliseconds: + (UInt32)h2ConnectionKeepaliveIdleIntervalMilliseconds + h2ConnectionKeepaliveTimeoutSeconds:(UInt32)h2ConnectionKeepaliveTimeoutSeconds + statsFlushSeconds:(UInt32)statsFlushSeconds + streamIdleTimeoutSeconds:(UInt32)streamIdleTimeoutSeconds + appVersion:(NSString *)appVersion + appId:(NSString *)appId + virtualClusters:(NSString *)virtualClusters + directResponseMatchers:(NSString *)directResponseMatchers + directResponses:(NSString *)directResponses + nativeFilterChain: + (NSArray *)nativeFilterChain + platformFilterChain: + (NSArray *)httpPlatformFilterFactories + stringAccessors: + (NSDictionary *) + stringAccessors { self = [super init]; if (!self) { return nil; @@ -41,7 +44,8 @@ @implementation EnvoyConfiguration self.dnsQueryTimeoutSeconds = dnsQueryTimeoutSeconds; self.dnsPreresolveHostnames = dnsPreresolveHostnames; self.h2ConnectionKeepaliveIntervalSeconds = h2ConnectionKeepaliveIntervalSeconds; - self.h2ConnectionKeepaliveIdleIntervalMilliseconds = h2ConnectionKeepaliveIdleIntervalMilliseconds; + self.h2ConnectionKeepaliveIdleIntervalMilliseconds = + h2ConnectionKeepaliveIdleIntervalMilliseconds; self.h2ConnectionKeepaliveTimeoutSeconds = h2ConnectionKeepaliveTimeoutSeconds; self.statsFlushSeconds = statsFlushSeconds; self.streamIdleTimeoutSeconds = streamIdleTimeoutSeconds; @@ -114,9 +118,12 @@ - (nullable NSString *)resolveTemplate:(NSString *)templateYAML { [definitions appendFormat:@"- &dns_query_timeout %lus\n", (unsigned long)self.dnsQueryTimeoutSeconds]; [definitions appendFormat:@"- &dns_preresolve_hostnames %@\n", self.dnsPreresolveHostnames]; - [definitions appendFormat:@"- &h2_connection_keepalive_interval %lus\n", (unsigned long)self.h2ConnectionKeepaliveIntervalSeconds]; - [definitions appendFormat:@"- &h2_connection_keepalive_idle_interval %lums\n", (unsigned long)self.h2ConnectionKeepaliveIdleIntervalMilliseconds]; - [definitions appendFormat:@"- &h2_connection_keepalive_timeout %lus\n", (unsigned long)self.h2ConnectionKeepaliveTimeoutSeconds]; + [definitions appendFormat:@"- &h2_connection_keepalive_interval %lus\n", + (unsigned long)self.h2ConnectionKeepaliveIntervalSeconds]; + [definitions appendFormat:@"- &h2_connection_keepalive_idle_interval %lums\n", + (unsigned long)self.h2ConnectionKeepaliveIdleIntervalMilliseconds]; + [definitions appendFormat:@"- &h2_connection_keepalive_timeout %lus\n", + (unsigned long)self.h2ConnectionKeepaliveTimeoutSeconds]; [definitions appendFormat:@"- &stream_idle_timeout %lus\n", (unsigned long)self.streamIdleTimeoutSeconds]; [definitions appendFormat:@"- &metadata { device_os: %@, app_version: %@, app_id: %@ }\n", @"iOS", diff --git a/library/objective-c/EnvoyEngine.h b/library/objective-c/EnvoyEngine.h index 4694618950..ccbfe0db97 100644 --- a/library/objective-c/EnvoyEngine.h +++ b/library/objective-c/EnvoyEngine.h @@ -318,29 +318,32 @@ extern const int kEnvoyFilterResumeStatusResumeIteration; /** Create a new instance of the configuration. */ -- (instancetype) - initWithAdminInterfaceEnabled:(BOOL)adminInterfaceEnabled - GrpcStatsDomain:(nullable NSString *)grpcStatsDomain - connectTimeoutSeconds:(UInt32)connectTimeoutSeconds - dnsRefreshSeconds:(UInt32)dnsRefreshSeconds - dnsFailureRefreshSecondsBase:(UInt32)dnsFailureRefreshSecondsBase - dnsFailureRefreshSecondsMax:(UInt32)dnsFailureRefreshSecondsMax - dnsQueryTimeoutSeconds:(UInt32)dnsQueryTimeoutSeconds - dnsPreresolveHostnames:(NSString *)dnsPreresolveHostnames - h2ConnectionKeepaliveIntervalSeconds:(UInt32)h2ConnectionKeepaliveIntervalSeconds - h2ConnectionKeepaliveIdleIntervalMilliseconds:(UInt32)h2ConnectionKeepaliveIdleIntervalMilliseconds - h2ConnectionKeepaliveTimeoutSeconds:(UInt32)h2ConnectionKeepaliveTimeoutSeconds - statsFlushSeconds:(UInt32)statsFlushSeconds - streamIdleTimeoutSeconds:(UInt32)streamIdleTimeoutSeconds - appVersion:(NSString *)appVersion - appId:(NSString *)appId - virtualClusters:(NSString *)virtualClusters - directResponseMatchers:(NSString *)directResponseMatchers - directResponses:(NSString *)directResponses - nativeFilterChain:(NSArray *)nativeFilterChain - platformFilterChain:(NSArray *)httpPlatformFilterFactories - stringAccessors: - (NSDictionary *)stringAccessors; +- (instancetype)initWithAdminInterfaceEnabled:(BOOL)adminInterfaceEnabled + GrpcStatsDomain:(nullable NSString *)grpcStatsDomain + connectTimeoutSeconds:(UInt32)connectTimeoutSeconds + dnsRefreshSeconds:(UInt32)dnsRefreshSeconds + dnsFailureRefreshSecondsBase:(UInt32)dnsFailureRefreshSecondsBase + dnsFailureRefreshSecondsMax:(UInt32)dnsFailureRefreshSecondsMax + dnsQueryTimeoutSeconds:(UInt32)dnsQueryTimeoutSeconds + dnsPreresolveHostnames:(NSString *)dnsPreresolveHostnames + h2ConnectionKeepaliveIntervalSeconds:(UInt32)h2ConnectionKeepaliveIntervalSeconds + h2ConnectionKeepaliveIdleIntervalMilliseconds: + (UInt32)h2ConnectionKeepaliveIdleIntervalMilliseconds + h2ConnectionKeepaliveTimeoutSeconds:(UInt32)h2ConnectionKeepaliveTimeoutSeconds + statsFlushSeconds:(UInt32)statsFlushSeconds + streamIdleTimeoutSeconds:(UInt32)streamIdleTimeoutSeconds + appVersion:(NSString *)appVersion + appId:(NSString *)appId + virtualClusters:(NSString *)virtualClusters + directResponseMatchers:(NSString *)directResponseMatchers + directResponses:(NSString *)directResponses + nativeFilterChain: + (NSArray *)nativeFilterChain + platformFilterChain: + (NSArray *)httpPlatformFilterFactories + stringAccessors: + (NSDictionary *) + stringAccessors; /** Resolves the provided configuration template using properties on this configuration. diff --git a/library/swift/EngineBuilder.swift b/library/swift/EngineBuilder.swift index 1997be4b13..ccabd73916 100644 --- a/library/swift/EngineBuilder.swift +++ b/library/swift/EngineBuilder.swift @@ -139,19 +139,23 @@ open class EngineBuilder: NSObject { /// /// - returns: This builder. @discardableResult - public func addH2ConnectionKeepaliveIntervalSeconds(_ h2ConnectionKeepaliveIntervalSeconds: UInt32) -> Self { + public func addH2ConnectionKeepaliveIntervalSeconds( + _ h2ConnectionKeepaliveIntervalSeconds: UInt32) -> Self { self.h2ConnectionKeepaliveIntervalSeconds = h2ConnectionKeepaliveIntervalSeconds return self } - /// Add a rate at which to ping h2 connections on new stream creation if the connection has sat idle. + /// Add a rate at which to ping h2 connections on new stream creation if the connection has + /// sat idle. /// /// - parameter h2ConnectionKeepaliveIdleIntervalMilliseconds: Rate in milliseconds. /// /// - returns: This builder. @discardableResult - public func addH2ConnectionKeepaliveIdleIntervalMilliseconds(_ h2ConnectionKeepaliveIdleIntervalMilliseconds: UInt32) -> Self { - self.h2ConnectionKeepaliveIdleIntervalMilliseconds = h2ConnectionKeepaliveIdleIntervalMilliseconds + public func addH2ConnectionKeepaliveIdleIntervalMilliseconds( + _ h2ConnectionKeepaliveIdleIntervalMilliseconds: UInt32) -> Self { + self.h2ConnectionKeepaliveIdleIntervalMilliseconds = + h2ConnectionKeepaliveIdleIntervalMilliseconds return self } @@ -161,7 +165,8 @@ open class EngineBuilder: NSObject { /// /// - returns: This builder. @discardableResult - public func addH2ConnectionKeepaliveTimeoutSeconds(_ h2ConnectionKeepaliveTimeoutSeconds: UInt32) -> Self { + public func addH2ConnectionKeepaliveTimeoutSeconds( + _ h2ConnectionKeepaliveTimeoutSeconds: UInt32) -> Self { self.h2ConnectionKeepaliveTimeoutSeconds = h2ConnectionKeepaliveTimeoutSeconds return self } @@ -335,8 +340,10 @@ open class EngineBuilder: NSObject { dnsFailureRefreshSecondsMax: self.dnsFailureRefreshSecondsMax, dnsQueryTimeoutSeconds: self.dnsQueryTimeoutSeconds, dnsPreresolveHostnames: self.dnsPreresolveHostnames, - h2ConnectionKeepaliveIntervalSeconds: self.h2ConnectionKeepaliveIntervalSeconds, - h2ConnectionKeepaliveIdleIntervalMilliseconds: self.h2ConnectionKeepaliveIdleIntervalMilliseconds, + h2ConnectionKeepaliveIntervalSeconds: + self.h2ConnectionKeepaliveIntervalSeconds, + h2ConnectionKeepaliveIdleIntervalMilliseconds: + self.h2ConnectionKeepaliveIdleIntervalMilliseconds, h2ConnectionKeepaliveTimeoutSeconds: self.h2ConnectionKeepaliveTimeoutSeconds, statsFlushSeconds: self.statsFlushSeconds, streamIdleTimeoutSeconds: self.streamIdleTimeoutSeconds, diff --git a/test/swift/EngineBuilderTests.swift b/test/swift/EngineBuilderTests.swift index 99be585881..6935257e81 100644 --- a/test/swift/EngineBuilderTests.swift +++ b/test/swift/EngineBuilderTests.swift @@ -166,7 +166,7 @@ final class EngineBuilderTests: XCTestCase { self.waitForExpectations(timeout: 0.01) } - func testAddingH2ConnectionKeepaliveIdleIntervalMillisecondsAddsToConfigurationWhenRunningEnvoy() { + func testAddingH2ConnectionKeepaliveIdleIntervalMSAddsToConfigurationWhenRunningEnvoy() { let expectation = self.expectation(description: "Run called with expected data") MockEnvoyEngine.onRunWithConfig = { config, _ in XCTAssertEqual(234, config.h2ConnectionKeepaliveIdleIntervalMilliseconds) From f057602978c98809a7ea5a9c720e7779dbbbbe55 Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Wed, 1 Sep 2021 16:17:22 -0700 Subject: [PATCH 3/8] cc fix Signed-off-by: Jose Nino --- library/cc/engine_builder.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/cc/engine_builder.h b/library/cc/engine_builder.h index e4efadf982..3fcd23a148 100644 --- a/library/cc/engine_builder.h +++ b/library/cc/engine_builder.h @@ -59,9 +59,10 @@ class EngineBuilder { int dns_failure_refresh_seconds_max_ = 10; int dns_query_timeout_seconds_ = 25; std::string dns_preresolve_hostnames_ = "[]"; - int h2_connection_keepalive_interval_seconds = - 2 int h2_connection_keepalive_idle_interval_milliseconds = - 1 int h2_connection_keepalive_timeout_seconds = 5 int stats_flush_seconds_ = 60; + int h2_connection_keepalive_interval_seconds_ = 2; + int h2_connection_keepalive_idle_interval_milliseconds_ = 1; + int h2_connection_keepalive_timeout_seconds_ = 5; + int stats_flush_seconds_ = 60; std::string app_version_ = "unspecified"; std::string app_id_ = "unspecified"; std::string device_os_ = "unspecified"; From dc5a502f15442e237e10179338b5d1191cf0ded0 Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Wed, 1 Sep 2021 16:54:07 -0700 Subject: [PATCH 4/8] update Signed-off-by: Jose Nino --- library/cc/engine_builder.cc | 2 +- library/cc/engine_builder.h | 4 ++-- library/common/config/config.cc | 6 +++++- .../envoyproxy/envoymobile/engine/EnvoyConfiguration.java | 4 ++-- library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt | 4 ++-- library/objective-c/EnvoyConfiguration.m | 4 ++-- library/swift/EngineBuilder.swift | 4 ++-- test/cc/unit/envoy_config_test.cc | 2 +- .../envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt | 2 +- test/swift/EngineBuilderTests.swift | 2 +- 10 files changed, 19 insertions(+), 15 deletions(-) diff --git a/library/cc/engine_builder.cc b/library/cc/engine_builder.cc index 4b68b37bdb..8d57a7ad06 100644 --- a/library/cc/engine_builder.cc +++ b/library/cc/engine_builder.cc @@ -109,7 +109,7 @@ std::string EngineBuilder::generateConfigStr() { {"h2_connection_keepalive_interval", fmt::format("{}s", this->h2_connection_keepalive_interval_seconds_)}, {"h2_connection_keepalive_idle_interval", - fmt::format("{}s", this->h2_connection_keepalive_idle_interval_milliseconds_)}, + fmt::format("{}s", this->h2_connection_keepalive_idle_interval_milliseconds_ / 1000.0)}, {"h2_connection_keepalive_timeout", fmt::format("{}s", this->h2_connection_keepalive_timeout_seconds_)}, { diff --git a/library/cc/engine_builder.h b/library/cc/engine_builder.h index 3fcd23a148..36cb1f5eb0 100644 --- a/library/cc/engine_builder.h +++ b/library/cc/engine_builder.h @@ -59,8 +59,8 @@ class EngineBuilder { int dns_failure_refresh_seconds_max_ = 10; int dns_query_timeout_seconds_ = 25; std::string dns_preresolve_hostnames_ = "[]"; - int h2_connection_keepalive_interval_seconds_ = 2; - int h2_connection_keepalive_idle_interval_milliseconds_ = 1; + int h2_connection_keepalive_interval_seconds_ = 0; + int h2_connection_keepalive_idle_interval_milliseconds_ = 0; int h2_connection_keepalive_timeout_seconds_ = 5; int stats_flush_seconds_ = 60; std::string app_version_ = "unspecified"; diff --git a/library/common/config/config.cc b/library/common/config/config.cc index 5a99558885..090f73fc4f 100644 --- a/library/common/config/config.cc +++ b/library/common/config/config.cc @@ -73,7 +73,11 @@ const std::string config_header = R"( envoy.extensions.upstreams.http.v3.HttpProtocolOptions: "@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions auto_config: - http2_protocol_options: {} + http2_protocol_options: + connection_keepalive: + interval: *h2_connection_keepalive_interval + connection_idle_interval: *h2_connection_keepalive_idle_interval + timeout: *h2_connection_keepalive_timeout http_protocol_options: header_key_format: stateful_formatter: diff --git a/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java b/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java index 0b1a4711db..ec63ee641a 100644 --- a/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java +++ b/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java @@ -133,8 +133,8 @@ String resolveTemplate(final String templateYAML, final String platformFilterTem .append(String.format("- &dns_preresolve_hostnames %s\n", dnsPreresolveHostnames)) .append(String.format("- &h2_connection_keepalive_interval %ss\n", h2ConnectionKeepaliveIntervalSeconds)) - .append(String.format("- &h2_connection_keepalive_idle_interval %sms\n", - h2ConnectionKeepaliveIdleIntervalMilliseconds)) + .append(String.format("- &h2_connection_keepalive_idle_interval %ss\n", + h2ConnectionKeepaliveIdleIntervalMilliseconds / 1000.0)) .append(String.format("- &h2_connection_keepalive_timeout %ss\n", h2ConnectionKeepaliveTimeoutSeconds)) .append(String.format("- &stream_idle_timeout %ss\n", streamIdleTimeoutSeconds)) diff --git a/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt b/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt index 6b84cc7345..72833131d0 100644 --- a/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt +++ b/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt @@ -35,8 +35,8 @@ open class EngineBuilder( private var dnsFailureRefreshSecondsMax = 10 private var dnsQueryTimeoutSeconds = 25 private var dnsPreresolveHostnames = "[]" - private var h2ConnectionKeepaliveIntervalSeconds = 2 - private var h2ConnectionKeepaliveIdleIntervalMilliseconds = 1 + private var h2ConnectionKeepaliveIntervalSeconds = 0 + private var h2ConnectionKeepaliveIdleIntervalMilliseconds = 0 private var h2ConnectionKeepaliveTimeoutSeconds = 5 private var statsFlushSeconds = 60 private var streamIdleTimeoutSeconds = 15 diff --git a/library/objective-c/EnvoyConfiguration.m b/library/objective-c/EnvoyConfiguration.m index 257a41560f..e92f9683de 100644 --- a/library/objective-c/EnvoyConfiguration.m +++ b/library/objective-c/EnvoyConfiguration.m @@ -120,8 +120,8 @@ - (nullable NSString *)resolveTemplate:(NSString *)templateYAML { [definitions appendFormat:@"- &dns_preresolve_hostnames %@\n", self.dnsPreresolveHostnames]; [definitions appendFormat:@"- &h2_connection_keepalive_interval %lus\n", (unsigned long)self.h2ConnectionKeepaliveIntervalSeconds]; - [definitions appendFormat:@"- &h2_connection_keepalive_idle_interval %lums\n", - (unsigned long)self.h2ConnectionKeepaliveIdleIntervalMilliseconds]; + [definitions appendFormat:@"- &h2_connection_keepalive_idle_interval %lus\n", + (unsigned long)self.h2ConnectionKeepaliveIdleIntervalMilliseconds / 1000.0]; [definitions appendFormat:@"- &h2_connection_keepalive_timeout %lus\n", (unsigned long)self.h2ConnectionKeepaliveTimeoutSeconds]; [definitions diff --git a/library/swift/EngineBuilder.swift b/library/swift/EngineBuilder.swift index ccabd73916..e16fc80f44 100644 --- a/library/swift/EngineBuilder.swift +++ b/library/swift/EngineBuilder.swift @@ -21,8 +21,8 @@ open class EngineBuilder: NSObject { private var dnsFailureRefreshSecondsMax: UInt32 = 10 private var dnsQueryTimeoutSeconds: UInt32 = 25 private var dnsPreresolveHostnames: String = "[]" - private var h2ConnectionKeepaliveIntervalSeconds: UInt32 = 2 - private var h2ConnectionKeepaliveIdleIntervalMilliseconds: UInt32 = 1 + private var h2ConnectionKeepaliveIntervalSeconds: UInt32 = 0 + private var h2ConnectionKeepaliveIdleIntervalMilliseconds: UInt32 = 0 private var h2ConnectionKeepaliveTimeoutSeconds: UInt32 = 5 private var statsFlushSeconds: UInt32 = 60 private var streamIdleTimeoutSeconds: UInt32 = 15 diff --git a/test/cc/unit/envoy_config_test.cc b/test/cc/unit/envoy_config_test.cc index d6f45f8a7c..da5bf3aa20 100644 --- a/test/cc/unit/envoy_config_test.cc +++ b/test/cc/unit/envoy_config_test.cc @@ -38,7 +38,7 @@ TEST(TestConfig, ConfigIsApplied) { "- &dns_query_timeout 321s", "- &dns_preresolve_hostnames [hostname]", "- &h2_connection_keepalive_interval 111s" - "- &h2_connection_keepalive_idle_interval 222ms" + "- &h2_connection_keepalive_idle_interval 0.222s" "- &h2_connection_keepalive_timeout 333s" "- &stats_flush_interval 654s", "- &virtual_clusters [virtual-clusters]", diff --git a/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt b/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt index 80223857ae..47bdb7cc75 100644 --- a/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt +++ b/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt @@ -49,7 +49,7 @@ class EnvoyConfigurationTest { // H2 Ping assertThat(resolvedTemplate).contains("&h2_connection_keepalive_interval 111s") - assertThat(resolvedTemplate).contains("&h2_connection_keepalive_idle_interval 222ms") + assertThat(resolvedTemplate).contains("&h2_connection_keepalive_idle_interval 0.222s") assertThat(resolvedTemplate).contains("&h2_connection_keepalive_timeout 333s") // Metadata diff --git a/test/swift/EngineBuilderTests.swift b/test/swift/EngineBuilderTests.swift index 6935257e81..e8afaee9d1 100644 --- a/test/swift/EngineBuilderTests.swift +++ b/test/swift/EngineBuilderTests.swift @@ -343,7 +343,7 @@ final class EngineBuilderTests: XCTestCase { XCTAssertTrue(resolvedYAML.contains("&dns_preresolve_hostnames [test]")) XCTAssertTrue(resolvedYAML.contains("&h2_connection_keepalive_interval 111s")) - XCTAssertTrue(resolvedYAML.contains("&h2_connection_keepalive_idle_interval 222ms")) + XCTAssertTrue(resolvedYAML.contains("&h2_connection_keepalive_idle_interval 0.222s")) XCTAssertTrue(resolvedYAML.contains("&h2_connection_keepalive_timeout 333s")) XCTAssertTrue(resolvedYAML.contains("&stream_idle_timeout 700s")) From 4f7e7df905bcc1d8fee4eb7f73739fbbc840e042 Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Thu, 2 Sep 2021 14:53:36 -0700 Subject: [PATCH 5/8] remove interval Signed-off-by: Jose Nino --- library/cc/engine_builder.cc | 8 ----- library/cc/engine_builder.h | 3 -- library/common/config/config.cc | 4 +-- .../engine/EnvoyConfiguration.java | 7 +---- .../envoyproxy/envoymobile/EngineBuilder.kt | 29 +++++++------------ library/objective-c/EnvoyConfiguration.m | 8 ++--- library/objective-c/EnvoyEngine.h | 2 -- library/swift/EngineBuilder.swift | 15 ---------- test/cc/unit/envoy_config_test.cc | 2 -- .../engine/EnvoyConfigurationTest.kt | 7 ++--- .../envoymobile/EngineBuilderTest.kt | 10 ------- test/swift/EngineBuilderTests.swift | 21 ++------------ 12 files changed, 19 insertions(+), 97 deletions(-) diff --git a/library/cc/engine_builder.cc b/library/cc/engine_builder.cc index 8d57a7ad06..3ff9a5cff3 100644 --- a/library/cc/engine_builder.cc +++ b/library/cc/engine_builder.cc @@ -54,12 +54,6 @@ EngineBuilder::addDnsPreresolveHostnames(const std::string& dns_preresolve_hostn return *this; } -EngineBuilder& EngineBuilder::addH2ConnectionKeepaliveIntervalSeconds( - int h2_connection_keepalive_interval_seconds) { - this->h2_connection_keepalive_interval_seconds_ = h2_connection_keepalive_interval_seconds; - return *this; -} - EngineBuilder& EngineBuilder::addH2ConnectionKeepaliveIdleIntervalMilliseconds( int h2_connection_keepalive_idle_interval_milliseconds) { this->h2_connection_keepalive_idle_interval_milliseconds_ = @@ -106,8 +100,6 @@ std::string EngineBuilder::generateConfigStr() { {"dns_preresolve_hostnames", this->dns_preresolve_hostnames_}, {"dns_refresh_rate", fmt::format("{}s", this->dns_refresh_seconds_)}, {"dns_query_timeout", fmt::format("{}s", this->dns_query_timeout_seconds_)}, - {"h2_connection_keepalive_interval", - fmt::format("{}s", this->h2_connection_keepalive_interval_seconds_)}, {"h2_connection_keepalive_idle_interval", fmt::format("{}s", this->h2_connection_keepalive_idle_interval_milliseconds_ / 1000.0)}, {"h2_connection_keepalive_timeout", diff --git a/library/cc/engine_builder.h b/library/cc/engine_builder.h index 36cb1f5eb0..d0dc299c5b 100644 --- a/library/cc/engine_builder.h +++ b/library/cc/engine_builder.h @@ -24,8 +24,6 @@ class EngineBuilder { EngineBuilder& addDnsFailureRefreshSeconds(int base, int max); EngineBuilder& addDnsQueryTimeoutSeconds(int dns_query_timeout_seconds); EngineBuilder& addDnsPreresolveHostnames(const std::string& dns_preresolve_hostnames); - EngineBuilder& - addH2ConnectionKeepaliveIntervalSeconds(int h2_connection_keepalive_interval_seconds); EngineBuilder& addH2ConnectionKeepaliveIdleIntervalMilliseconds( int h2_connection_keepalive_idle_interval_milliseconds); EngineBuilder& @@ -59,7 +57,6 @@ class EngineBuilder { int dns_failure_refresh_seconds_max_ = 10; int dns_query_timeout_seconds_ = 25; std::string dns_preresolve_hostnames_ = "[]"; - int h2_connection_keepalive_interval_seconds_ = 0; int h2_connection_keepalive_idle_interval_milliseconds_ = 0; int h2_connection_keepalive_timeout_seconds_ = 5; int stats_flush_seconds_ = 60; diff --git a/library/common/config/config.cc b/library/common/config/config.cc index 1b423077b7..2f491afc23 100644 --- a/library/common/config/config.cc +++ b/library/common/config/config.cc @@ -39,8 +39,7 @@ const std::string config_header = R"( - &dns_fail_max_interval 10s - &dns_query_timeout 25s - &dns_preresolve_hostnames [] -- &h2_connection_keepalive_interval 0s -- &h2_connection_keepalive_idle_interval 0s +- &h2_connection_keepalive_idle_interval 100000s - &h2_connection_keepalive_timeout 5s - &metadata {} - &stats_domain 127.0.0.1 @@ -75,7 +74,6 @@ const std::string config_header = R"( auto_config: http2_protocol_options: connection_keepalive: - interval: *h2_connection_keepalive_interval connection_idle_interval: *h2_connection_keepalive_idle_interval timeout: *h2_connection_keepalive_timeout http_protocol_options: diff --git a/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java b/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java index ec63ee641a..c2e61fdb9e 100644 --- a/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java +++ b/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java @@ -20,7 +20,6 @@ public class EnvoyConfiguration { public final Integer dnsFailureRefreshSecondsMax; public final Integer dnsQueryTimeoutSeconds; public final String dnsPreresolveHostnames; - public final Integer h2ConnectionKeepaliveIntervalSeconds; public final Integer h2ConnectionKeepaliveIdleIntervalMilliseconds; public final Integer h2ConnectionKeepaliveTimeoutSeconds; public final List httpPlatformFilterFactories; @@ -46,7 +45,6 @@ public class EnvoyConfiguration { * @param dnsFailureRefreshSecondsMax max rate in seconds to refresh DNS on failure. * @param dnsQueryTimeoutSeconds rate in seconds to timeout DNS queries. * @param dnsPreresolveHostnames hostnames to preresolve on Envoy Client construction. - * @param h2ConnectionKeepaliveIntervalSeconds rate in seconds to send h2 pings. * @param h2ConnectionKeepaliveIdleIntervalMilliseconds rate in milliseconds seconds to send h2 * pings on stream creation. * @param h2ConnectionKeepaliveTimeoutSeconds rate in seconds to timeout h2 pings. @@ -63,7 +61,7 @@ public EnvoyConfiguration(Boolean adminInterfaceEnabled, String grpcStatsDomain, @Nullable Integer statsdPort, int connectTimeoutSeconds, int dnsRefreshSeconds, int dnsFailureRefreshSecondsBase, int dnsFailureRefreshSecondsMax, int dnsQueryTimeoutSeconds, - String dnsPreresolveHostnames, int h2ConnectionKeepaliveIntervalSeconds, + String dnsPreresolveHostnames, int h2ConnectionKeepaliveIdleIntervalMilliseconds, int h2ConnectionKeepaliveTimeoutSeconds, int statsFlushSeconds, int streamIdleTimeoutSeconds, String appVersion, String appId, @@ -79,7 +77,6 @@ public EnvoyConfiguration(Boolean adminInterfaceEnabled, String grpcStatsDomain, this.dnsFailureRefreshSecondsMax = dnsFailureRefreshSecondsMax; this.dnsQueryTimeoutSeconds = dnsQueryTimeoutSeconds; this.dnsPreresolveHostnames = dnsPreresolveHostnames; - this.h2ConnectionKeepaliveIntervalSeconds = h2ConnectionKeepaliveIntervalSeconds; this.h2ConnectionKeepaliveIdleIntervalMilliseconds = h2ConnectionKeepaliveIdleIntervalMilliseconds; this.h2ConnectionKeepaliveTimeoutSeconds = h2ConnectionKeepaliveTimeoutSeconds; @@ -131,8 +128,6 @@ String resolveTemplate(final String templateYAML, final String platformFilterTem .append(String.format("- &dns_fail_max_interval %ss\n", dnsFailureRefreshSecondsMax)) .append(String.format("- &dns_query_timeout %ss\n", dnsQueryTimeoutSeconds)) .append(String.format("- &dns_preresolve_hostnames %s\n", dnsPreresolveHostnames)) - .append(String.format("- &h2_connection_keepalive_interval %ss\n", - h2ConnectionKeepaliveIntervalSeconds)) .append(String.format("- &h2_connection_keepalive_idle_interval %ss\n", h2ConnectionKeepaliveIdleIntervalMilliseconds / 1000.0)) .append(String.format("- &h2_connection_keepalive_timeout %ss\n", diff --git a/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt b/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt index 72833131d0..6b34ce374c 100644 --- a/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt +++ b/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt @@ -35,7 +35,6 @@ open class EngineBuilder( private var dnsFailureRefreshSecondsMax = 10 private var dnsQueryTimeoutSeconds = 25 private var dnsPreresolveHostnames = "[]" - private var h2ConnectionKeepaliveIntervalSeconds = 0 private var h2ConnectionKeepaliveIdleIntervalMilliseconds = 0 private var h2ConnectionKeepaliveTimeoutSeconds = 5 private var statsFlushSeconds = 60 @@ -152,26 +151,17 @@ open class EngineBuilder( } /** - * Add a rate at which to ping h2 connections. - * - * @param h2ConnectionKeepaliveIntervalSeconds rate in seconds to ping h2 connections. - * - * @return this builder. - */ - fun addH2ConnectionKeepaliveIntervalSeconds(h2ConnectionKeepaliveIntervalSeconds: Int): EngineBuilder { - this.h2ConnectionKeepaliveIntervalSeconds = h2ConnectionKeepaliveIntervalSeconds - return this - } - - /** - * Add a rate at which to ping h2 connections on new stream creation if the connection has sat idle. + * Add a rate at which to ping h2 connections on new stream creation if the connection has + * sat idle. * * @param h2ConnectionKeepaliveIdleIntervalMilliseconds rate in milliseconds. * * @return this builder. */ - fun addH2ConnectionKeepaliveIdleIntervalMilliseconds(h2ConnectionKeepaliveIdleIntervalMilliseconds: Int): EngineBuilder { - this.h2ConnectionKeepaliveIdleIntervalMilliseconds = h2ConnectionKeepaliveIdleIntervalMilliseconds + fun addH2ConnectionKeepaliveIdleIntervalMilliseconds( + h2ConnectionKeepaliveIdleIntervalMilliseconds: Int): EngineBuilder { + this.h2ConnectionKeepaliveIdleIntervalMilliseconds = + h2ConnectionKeepaliveIdleIntervalMilliseconds return this } @@ -182,7 +172,8 @@ open class EngineBuilder( * * @return this builder. */ - fun addH2ConnectionKeepaliveTimeoutSeconds(h2ConnectionKeepaliveTimeoutSeconds: Int): EngineBuilder { + fun addH2ConnectionKeepaliveTimeoutSeconds( + h2ConnectionKeepaliveTimeoutSeconds: Int): EngineBuilder { this.h2ConnectionKeepaliveTimeoutSeconds = h2ConnectionKeepaliveTimeoutSeconds return this } @@ -360,7 +351,7 @@ open class EngineBuilder( EnvoyConfiguration( adminInterfaceEnabled, grpcStatsDomain, statsDPort, connectTimeoutSeconds, dnsRefreshSeconds, dnsFailureRefreshSecondsBase, dnsFailureRefreshSecondsMax, - dnsQueryTimeoutSeconds, dnsPreresolveHostnames, h2ConnectionKeepaliveIntervalSeconds, + dnsQueryTimeoutSeconds, dnsPreresolveHostnames, h2ConnectionKeepaliveIdleIntervalMilliseconds, h2ConnectionKeepaliveTimeoutSeconds, statsFlushSeconds, streamIdleTimeoutSeconds, appVersion, appId, virtualClusters, nativeFilterChain, platformFilterChain, stringAccessors @@ -375,7 +366,7 @@ open class EngineBuilder( EnvoyConfiguration( adminInterfaceEnabled, grpcStatsDomain, statsDPort, connectTimeoutSeconds, dnsRefreshSeconds, dnsFailureRefreshSecondsBase, dnsFailureRefreshSecondsMax, - dnsQueryTimeoutSeconds, dnsPreresolveHostnames, h2ConnectionKeepaliveIntervalSeconds, + dnsQueryTimeoutSeconds, dnsPreresolveHostnames, h2ConnectionKeepaliveIdleIntervalMilliseconds, h2ConnectionKeepaliveTimeoutSeconds, statsFlushSeconds, streamIdleTimeoutSeconds, appVersion, appId, virtualClusters, nativeFilterChain, platformFilterChain, stringAccessors diff --git a/library/objective-c/EnvoyConfiguration.m b/library/objective-c/EnvoyConfiguration.m index e92f9683de..4285275c73 100644 --- a/library/objective-c/EnvoyConfiguration.m +++ b/library/objective-c/EnvoyConfiguration.m @@ -12,7 +12,6 @@ - (instancetype)initWithAdminInterfaceEnabled:(BOOL)adminInterfaceEnabled dnsFailureRefreshSecondsMax:(UInt32)dnsFailureRefreshSecondsMax dnsQueryTimeoutSeconds:(UInt32)dnsQueryTimeoutSeconds dnsPreresolveHostnames:(NSString *)dnsPreresolveHostnames - h2ConnectionKeepaliveIntervalSeconds:(UInt32)h2ConnectionKeepaliveIntervalSeconds h2ConnectionKeepaliveIdleIntervalMilliseconds: (UInt32)h2ConnectionKeepaliveIdleIntervalMilliseconds h2ConnectionKeepaliveTimeoutSeconds:(UInt32)h2ConnectionKeepaliveTimeoutSeconds @@ -43,7 +42,6 @@ - (instancetype)initWithAdminInterfaceEnabled:(BOOL)adminInterfaceEnabled self.dnsFailureRefreshSecondsMax = dnsFailureRefreshSecondsMax; self.dnsQueryTimeoutSeconds = dnsQueryTimeoutSeconds; self.dnsPreresolveHostnames = dnsPreresolveHostnames; - self.h2ConnectionKeepaliveIntervalSeconds = h2ConnectionKeepaliveIntervalSeconds; self.h2ConnectionKeepaliveIdleIntervalMilliseconds = h2ConnectionKeepaliveIdleIntervalMilliseconds; self.h2ConnectionKeepaliveTimeoutSeconds = h2ConnectionKeepaliveTimeoutSeconds; @@ -118,10 +116,8 @@ - (nullable NSString *)resolveTemplate:(NSString *)templateYAML { [definitions appendFormat:@"- &dns_query_timeout %lus\n", (unsigned long)self.dnsQueryTimeoutSeconds]; [definitions appendFormat:@"- &dns_preresolve_hostnames %@\n", self.dnsPreresolveHostnames]; - [definitions appendFormat:@"- &h2_connection_keepalive_interval %lus\n", - (unsigned long)self.h2ConnectionKeepaliveIntervalSeconds]; - [definitions appendFormat:@"- &h2_connection_keepalive_idle_interval %lus\n", - (unsigned long)self.h2ConnectionKeepaliveIdleIntervalMilliseconds / 1000.0]; + [definitions appendFormat:@"- &h2_connection_keepalive_idle_interval %.*fs\n", 3, + (double)self.h2ConnectionKeepaliveIdleIntervalMilliseconds / 1000.0]; [definitions appendFormat:@"- &h2_connection_keepalive_timeout %lus\n", (unsigned long)self.h2ConnectionKeepaliveTimeoutSeconds]; [definitions diff --git a/library/objective-c/EnvoyEngine.h b/library/objective-c/EnvoyEngine.h index ccbfe0db97..a8b09c3933 100644 --- a/library/objective-c/EnvoyEngine.h +++ b/library/objective-c/EnvoyEngine.h @@ -301,7 +301,6 @@ extern const int kEnvoyFilterResumeStatusResumeIteration; @property (nonatomic, assign) UInt32 dnsFailureRefreshSecondsMax; @property (nonatomic, assign) UInt32 dnsQueryTimeoutSeconds; @property (nonatomic, strong) NSString *dnsPreresolveHostnames; -@property (nonatomic, assign) UInt32 h2ConnectionKeepaliveIntervalSeconds; @property (nonatomic, assign) UInt32 h2ConnectionKeepaliveIdleIntervalMilliseconds; @property (nonatomic, assign) UInt32 h2ConnectionKeepaliveTimeoutSeconds; @property (nonatomic, assign) UInt32 statsFlushSeconds; @@ -326,7 +325,6 @@ extern const int kEnvoyFilterResumeStatusResumeIteration; dnsFailureRefreshSecondsMax:(UInt32)dnsFailureRefreshSecondsMax dnsQueryTimeoutSeconds:(UInt32)dnsQueryTimeoutSeconds dnsPreresolveHostnames:(NSString *)dnsPreresolveHostnames - h2ConnectionKeepaliveIntervalSeconds:(UInt32)h2ConnectionKeepaliveIntervalSeconds h2ConnectionKeepaliveIdleIntervalMilliseconds: (UInt32)h2ConnectionKeepaliveIdleIntervalMilliseconds h2ConnectionKeepaliveTimeoutSeconds:(UInt32)h2ConnectionKeepaliveTimeoutSeconds diff --git a/library/swift/EngineBuilder.swift b/library/swift/EngineBuilder.swift index e16fc80f44..2fd765cc17 100644 --- a/library/swift/EngineBuilder.swift +++ b/library/swift/EngineBuilder.swift @@ -21,7 +21,6 @@ open class EngineBuilder: NSObject { private var dnsFailureRefreshSecondsMax: UInt32 = 10 private var dnsQueryTimeoutSeconds: UInt32 = 25 private var dnsPreresolveHostnames: String = "[]" - private var h2ConnectionKeepaliveIntervalSeconds: UInt32 = 0 private var h2ConnectionKeepaliveIdleIntervalMilliseconds: UInt32 = 0 private var h2ConnectionKeepaliveTimeoutSeconds: UInt32 = 5 private var statsFlushSeconds: UInt32 = 60 @@ -133,18 +132,6 @@ open class EngineBuilder: NSObject { return self } - /// Add a rate at which to ping h2 connections. - /// - /// - parameter h2ConnectionKeepaliveIntervalSeconds: Rate in seconds to ping h2 connections. - /// - /// - returns: This builder. - @discardableResult - public func addH2ConnectionKeepaliveIntervalSeconds( - _ h2ConnectionKeepaliveIntervalSeconds: UInt32) -> Self { - self.h2ConnectionKeepaliveIntervalSeconds = h2ConnectionKeepaliveIntervalSeconds - return self - } - /// Add a rate at which to ping h2 connections on new stream creation if the connection has /// sat idle. /// @@ -340,8 +327,6 @@ open class EngineBuilder: NSObject { dnsFailureRefreshSecondsMax: self.dnsFailureRefreshSecondsMax, dnsQueryTimeoutSeconds: self.dnsQueryTimeoutSeconds, dnsPreresolveHostnames: self.dnsPreresolveHostnames, - h2ConnectionKeepaliveIntervalSeconds: - self.h2ConnectionKeepaliveIntervalSeconds, h2ConnectionKeepaliveIdleIntervalMilliseconds: self.h2ConnectionKeepaliveIdleIntervalMilliseconds, h2ConnectionKeepaliveTimeoutSeconds: self.h2ConnectionKeepaliveTimeoutSeconds, diff --git a/test/cc/unit/envoy_config_test.cc b/test/cc/unit/envoy_config_test.cc index da5bf3aa20..bafccf61de 100644 --- a/test/cc/unit/envoy_config_test.cc +++ b/test/cc/unit/envoy_config_test.cc @@ -19,7 +19,6 @@ TEST(TestConfig, ConfigIsApplied) { .addDnsFailureRefreshSeconds(789, 987) .addDnsQueryTimeoutSeconds(321) .addDnsPreresolveHostnames("[hostname]") - .addH2ConnectionKeepaliveIntervalSeconds(111) .addH2ConnectionKeepaliveIdleIntervalMilliseconds(222) .addH2ConnectionKeepaliveTimeoutSeconds(333) .addStatsFlushSeconds(654) @@ -37,7 +36,6 @@ TEST(TestConfig, ConfigIsApplied) { "- &dns_fail_max_interval 987s", "- &dns_query_timeout 321s", "- &dns_preresolve_hostnames [hostname]", - "- &h2_connection_keepalive_interval 111s" "- &h2_connection_keepalive_idle_interval 0.222s" "- &h2_connection_keepalive_timeout 333s" "- &stats_flush_interval 654s", diff --git a/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt b/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt index 47bdb7cc75..fff7efa1c8 100644 --- a/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt +++ b/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt @@ -28,7 +28,7 @@ class EnvoyConfigurationTest { @Test fun `resolving with default configuration resolves with values`() { val envoyConfiguration = EnvoyConfiguration( - false, "stats.foo.com", null, 123, 234, 345, 456, 321, "[hostname]", 111, 222, 333, 567, 678, "v1.2.3", "com.mydomain.myapp", "[test]", + false, "stats.foo.com", null, 123, 234, 345, 456, 321, "[hostname]", 222, 333, 567, 678, "v1.2.3", "com.mydomain.myapp", "[test]", listOf(EnvoyNativeFilterConfig("filter_name", "test_config")), emptyList(), emptyMap() ) @@ -48,7 +48,6 @@ class EnvoyConfigurationTest { assertThat(resolvedTemplate).contains("&dns_preresolve_hostnames [hostname]") // H2 Ping - assertThat(resolvedTemplate).contains("&h2_connection_keepalive_interval 111s") assertThat(resolvedTemplate).contains("&h2_connection_keepalive_idle_interval 0.222s") assertThat(resolvedTemplate).contains("&h2_connection_keepalive_timeout 333s") @@ -71,7 +70,7 @@ class EnvoyConfigurationTest { @Test fun `resolve templates with invalid templates will throw on build`() { val envoyConfiguration = EnvoyConfiguration( - false, "stats.foo.com", null, 123, 234, 345, 456, 321, "[hostname]", 123, 123, 123, 567, 678, "v1.2.3", "com.mydomain.myapp", "[test]", + false, "stats.foo.com", null, 123, 234, 345, 456, 321, "[hostname]", 123, 123, 567, 678, "v1.2.3", "com.mydomain.myapp", "[test]", emptyList(), emptyList(), emptyMap() ) @@ -86,7 +85,7 @@ class EnvoyConfigurationTest { @Test fun `cannot configure both statsD and gRPC stat sink`() { val envoyConfiguration = EnvoyConfiguration( - false, "stats.foo.com", 5050, 123, 234, 345, 456, 321, "[hostname]", 123, 123, 123, 567, 678, "v1.2.3", "com.mydomain.myapp", "[test]", + false, "stats.foo.com", 5050, 123, 234, 345, 456, 321, "[hostname]", 123, 123, 567, 678, "v1.2.3", "com.mydomain.myapp", "[test]", emptyList(), emptyList(), emptyMap() ) diff --git a/test/kotlin/io/envoyproxy/envoymobile/EngineBuilderTest.kt b/test/kotlin/io/envoyproxy/envoymobile/EngineBuilderTest.kt index d7ea52f957..973f335136 100644 --- a/test/kotlin/io/envoyproxy/envoymobile/EngineBuilderTest.kt +++ b/test/kotlin/io/envoyproxy/envoymobile/EngineBuilderTest.kt @@ -80,16 +80,6 @@ class EngineBuilderTest { assertThat(engine.envoyConfiguration!!.dnsQueryTimeoutSeconds).isEqualTo(1234) } - @Test - fun `specifying H2 Ping interval overrides default`() { - engineBuilder = EngineBuilder(Standard()) - engineBuilder.addEngineType { envoyEngine } - engineBuilder.addH2ConnectionKeepaliveIntervalSeconds(111) - - val engine = engineBuilder.build() as EngineImpl - assertThat(engine.envoyConfiguration!!.h2ConnectionKeepaliveIntervalSeconds).isEqualTo(111) - } - @Test fun `specifying H2 Ping idle interval overrides default`() { engineBuilder = EngineBuilder(Standard()) diff --git a/test/swift/EngineBuilderTests.swift b/test/swift/EngineBuilderTests.swift index e8afaee9d1..09bb03392c 100644 --- a/test/swift/EngineBuilderTests.swift +++ b/test/swift/EngineBuilderTests.swift @@ -152,20 +152,6 @@ final class EngineBuilderTests: XCTestCase { self.waitForExpectations(timeout: 0.01) } - func testAddingH2ConnectionKeepaliveIntervalSecondsAddsToConfigurationWhenRunningEnvoy() { - let expectation = self.expectation(description: "Run called with expected data") - MockEnvoyEngine.onRunWithConfig = { config, _ in - XCTAssertEqual(234, config.h2ConnectionKeepaliveIntervalSeconds) - expectation.fulfill() - } - - _ = EngineBuilder() - .addEngineType(MockEnvoyEngine.self) - .addH2ConnectionKeepaliveIntervalSeconds(234) - .build() - self.waitForExpectations(timeout: 0.01) - } - func testAddingH2ConnectionKeepaliveIdleIntervalMSAddsToConfigurationWhenRunningEnvoy() { let expectation = self.expectation(description: "Run called with expected data") MockEnvoyEngine.onRunWithConfig = { config, _ in @@ -316,8 +302,7 @@ final class EngineBuilderTests: XCTestCase { dnsFailureRefreshSecondsMax: 500, dnsQueryTimeoutSeconds: 800, dnsPreresolveHostnames: "[test]", - h2ConnectionKeepaliveIntervalSeconds: 111, - h2ConnectionKeepaliveIdleIntervalMilliseconds: 222, + h2ConnectionKeepaliveIdleIntervalMilliseconds: 1, h2ConnectionKeepaliveTimeoutSeconds: 333, statsFlushSeconds: 600, streamIdleTimeoutSeconds: 700, @@ -342,8 +327,7 @@ final class EngineBuilderTests: XCTestCase { XCTAssertTrue(resolvedYAML.contains("&dns_query_timeout 800s")) XCTAssertTrue(resolvedYAML.contains("&dns_preresolve_hostnames [test]")) - XCTAssertTrue(resolvedYAML.contains("&h2_connection_keepalive_interval 111s")) - XCTAssertTrue(resolvedYAML.contains("&h2_connection_keepalive_idle_interval 0.222s")) + XCTAssertTrue(resolvedYAML.contains("&h2_connection_keepalive_idle_interval 0.001s")) XCTAssertTrue(resolvedYAML.contains("&h2_connection_keepalive_timeout 333s")) XCTAssertTrue(resolvedYAML.contains("&stream_idle_timeout 700s")) @@ -377,7 +361,6 @@ final class EngineBuilderTests: XCTestCase { dnsFailureRefreshSecondsMax: 500, dnsQueryTimeoutSeconds: 800, dnsPreresolveHostnames: "[test]", - h2ConnectionKeepaliveIntervalSeconds: 111, h2ConnectionKeepaliveIdleIntervalMilliseconds: 222, h2ConnectionKeepaliveTimeoutSeconds: 333, statsFlushSeconds: 600, From 0835d474d45e6d8dd674dbdfbf9a787c31979afd Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Thu, 2 Sep 2021 14:54:53 -0700 Subject: [PATCH 6/8] casing Signed-off-by: Jose Nino --- library/cc/engine_builder.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/cc/engine_builder.h b/library/cc/engine_builder.h index d0dc299c5b..de8b105c86 100644 --- a/library/cc/engine_builder.h +++ b/library/cc/engine_builder.h @@ -27,7 +27,7 @@ class EngineBuilder { EngineBuilder& addH2ConnectionKeepaliveIdleIntervalMilliseconds( int h2_connection_keepalive_idle_interval_milliseconds); EngineBuilder& - addh2ConnectionKeepaliveTimeoutSeconds(int h2_connection_keepalive_timeout_seconds); + addH2ConnectionKeepaliveTimeoutSeconds(int h2_connection_keepalive_timeout_seconds); EngineBuilder& addStatsFlushSeconds(int stats_flush_seconds); EngineBuilder& addVirtualClusters(const std::string& virtual_clusters); EngineBuilder& setAppVersion(const std::string& app_version); From 206d05ec2b9608742b5aa02f917924ef118f6a0b Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Thu, 2 Sep 2021 15:07:04 -0700 Subject: [PATCH 7/8] update Signed-off-by: Jose Nino --- library/cc/engine_builder.h | 4 ++-- library/common/config/config.cc | 2 +- library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt | 4 ++-- library/swift/EngineBuilder.swift | 4 ++-- test/cc/unit/envoy_config_test.cc | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/library/cc/engine_builder.h b/library/cc/engine_builder.h index de8b105c86..42360b3d83 100644 --- a/library/cc/engine_builder.h +++ b/library/cc/engine_builder.h @@ -57,8 +57,8 @@ class EngineBuilder { int dns_failure_refresh_seconds_max_ = 10; int dns_query_timeout_seconds_ = 25; std::string dns_preresolve_hostnames_ = "[]"; - int h2_connection_keepalive_idle_interval_milliseconds_ = 0; - int h2_connection_keepalive_timeout_seconds_ = 5; + int h2_connection_keepalive_idle_interval_milliseconds_ = 100000000; + int h2_connection_keepalive_timeout_seconds_ = 10; int stats_flush_seconds_ = 60; std::string app_version_ = "unspecified"; std::string app_id_ = "unspecified"; diff --git a/library/common/config/config.cc b/library/common/config/config.cc index 2f491afc23..e43140657a 100644 --- a/library/common/config/config.cc +++ b/library/common/config/config.cc @@ -40,7 +40,7 @@ const std::string config_header = R"( - &dns_query_timeout 25s - &dns_preresolve_hostnames [] - &h2_connection_keepalive_idle_interval 100000s -- &h2_connection_keepalive_timeout 5s +- &h2_connection_keepalive_timeout 10s - &metadata {} - &stats_domain 127.0.0.1 - &stats_flush_interval 60s diff --git a/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt b/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt index 6b34ce374c..3a0bf41055 100644 --- a/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt +++ b/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt @@ -35,8 +35,8 @@ open class EngineBuilder( private var dnsFailureRefreshSecondsMax = 10 private var dnsQueryTimeoutSeconds = 25 private var dnsPreresolveHostnames = "[]" - private var h2ConnectionKeepaliveIdleIntervalMilliseconds = 0 - private var h2ConnectionKeepaliveTimeoutSeconds = 5 + private var h2ConnectionKeepaliveIdleIntervalMilliseconds = 100000000 + private var h2ConnectionKeepaliveTimeoutSeconds = 10 private var statsFlushSeconds = 60 private var streamIdleTimeoutSeconds = 15 private var appVersion = "unspecified" diff --git a/library/swift/EngineBuilder.swift b/library/swift/EngineBuilder.swift index 2fd765cc17..18a3ca4d09 100644 --- a/library/swift/EngineBuilder.swift +++ b/library/swift/EngineBuilder.swift @@ -21,8 +21,8 @@ open class EngineBuilder: NSObject { private var dnsFailureRefreshSecondsMax: UInt32 = 10 private var dnsQueryTimeoutSeconds: UInt32 = 25 private var dnsPreresolveHostnames: String = "[]" - private var h2ConnectionKeepaliveIdleIntervalMilliseconds: UInt32 = 0 - private var h2ConnectionKeepaliveTimeoutSeconds: UInt32 = 5 + private var h2ConnectionKeepaliveIdleIntervalMilliseconds: UInt32 = 100000000 + private var h2ConnectionKeepaliveTimeoutSeconds: UInt32 = 10 private var statsFlushSeconds: UInt32 = 60 private var streamIdleTimeoutSeconds: UInt32 = 15 private var appVersion: String = "unspecified" diff --git a/test/cc/unit/envoy_config_test.cc b/test/cc/unit/envoy_config_test.cc index bafccf61de..2c7d556d67 100644 --- a/test/cc/unit/envoy_config_test.cc +++ b/test/cc/unit/envoy_config_test.cc @@ -36,8 +36,8 @@ TEST(TestConfig, ConfigIsApplied) { "- &dns_fail_max_interval 987s", "- &dns_query_timeout 321s", "- &dns_preresolve_hostnames [hostname]", - "- &h2_connection_keepalive_idle_interval 0.222s" - "- &h2_connection_keepalive_timeout 333s" + "- &h2_connection_keepalive_idle_interval 0.222s", + "- &h2_connection_keepalive_timeout 333s", "- &stats_flush_interval 654s", "- &virtual_clusters [virtual-clusters]", ("- &metadata { device_os: probably-ubuntu-on-CI, " From 35b5bba40a55ad126179091bad9c818f8d3b826b Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Thu, 2 Sep 2021 16:34:41 -0700 Subject: [PATCH 8/8] fmt Signed-off-by: Jose Nino --- .../kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt b/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt index 3a0bf41055..463916e76d 100644 --- a/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt +++ b/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt @@ -158,10 +158,8 @@ open class EngineBuilder( * * @return this builder. */ - fun addH2ConnectionKeepaliveIdleIntervalMilliseconds( - h2ConnectionKeepaliveIdleIntervalMilliseconds: Int): EngineBuilder { - this.h2ConnectionKeepaliveIdleIntervalMilliseconds = - h2ConnectionKeepaliveIdleIntervalMilliseconds + fun addH2ConnectionKeepaliveIdleIntervalMilliseconds(idleIntervalMs: Int): EngineBuilder { + this.h2ConnectionKeepaliveIdleIntervalMilliseconds = idleIntervalMs return this } @@ -172,9 +170,8 @@ open class EngineBuilder( * * @return this builder. */ - fun addH2ConnectionKeepaliveTimeoutSeconds( - h2ConnectionKeepaliveTimeoutSeconds: Int): EngineBuilder { - this.h2ConnectionKeepaliveTimeoutSeconds = h2ConnectionKeepaliveTimeoutSeconds + fun addH2ConnectionKeepaliveTimeoutSeconds(timeoutSeconds: Int): EngineBuilder { + this.h2ConnectionKeepaliveTimeoutSeconds = timeoutSeconds return this }