Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/java/hello_world/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import io.envoyproxy.envoymobile.AndroidEnvoyBuilder;
import io.envoyproxy.envoymobile.AndroidEnvoyClientBuilder;
import io.envoyproxy.envoymobile.Envoy;
import io.envoyproxy.envoymobile.Request;
import io.envoyproxy.envoymobile.RequestBuilder;
Expand Down Expand Up @@ -39,7 +39,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

envoy = new AndroidEnvoyBuilder(getBaseContext()).build();
envoy = new AndroidEnvoyClientBuilder(getBaseContext()).build();

recyclerView = findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
Expand Down
4 changes: 2 additions & 2 deletions examples/kotlin/hello_world/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.support.v7.widget.DividerItemDecoration
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.util.Log
import io.envoyproxy.envoymobile.AndroidEnvoyBuilder
import io.envoyproxy.envoymobile.AndroidEnvoyClientBuilder
import io.envoyproxy.envoymobile.Envoy
import io.envoyproxy.envoymobile.RequestBuilder
import io.envoyproxy.envoymobile.RequestMethod
Expand Down Expand Up @@ -37,7 +37,7 @@ class MainActivity : Activity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

envoy = AndroidEnvoyBuilder(baseContext).build()
envoy = AndroidEnvoyClientBuilder(baseContext).build()

recyclerView = findViewById(R.id.recycler_view) as RecyclerView
recyclerView.layoutManager = LinearLayoutManager(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package io.envoyproxy.envoymobile
import android.content.Context
import io.envoyproxy.envoymobile.engine.AndroidEngineImpl

class AndroidEnvoyBuilder(
class AndroidEnvoyClientBuilder(
context: Context
) : EnvoyBuilder() {
) : EnvoyClientBuilder() {

init {
addEngineType { AndroidEngineImpl(context) }
Expand Down
8 changes: 4 additions & 4 deletions library/kotlin/src/io/envoyproxy/envoymobile/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ aar_with_jni(
envoy_mobile_kt_aar_android_library(
name = "envoy_lib",
srcs = [
"AndroidEnvoyBuilder.kt",
"AndroidEnvoyClientBuilder.kt",
],
custom_package = "io.envoyproxy.envoymobile",
manifest = "EnvoyManifest.xml",
Expand All @@ -29,11 +29,11 @@ envoy_mobile_kt_aar_android_library(
envoy_mobile_kt_library(
name = "envoy_interfaces_lib",
srcs = [
"Client.kt",
"Envoy.kt",
"EnvoyBuilder.kt",
"EnvoyClient.kt",
"EnvoyClientBuilder.kt",
"EnvoyException.kt",
"EnvoyStreamEmitter.kt",
"HTTPClient.kt",
"Request.kt",
"RequestBuilder.kt",
"RequestMapper.kt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Envoy private constructor(
internal val envoyConfiguration: EnvoyConfiguration?,
internal val configurationYAML: String?,
internal val logLevel: LogLevel
) : Client {
) : HTTPClient {

constructor(engine: EnvoyEngine, envoyConfiguration: EnvoyConfiguration, logLevel: LogLevel = LogLevel.INFO) : this(engine, envoyConfiguration, null, logLevel)
constructor(engine: EnvoyEngine, configurationYAML: String, logLevel: LogLevel = LogLevel.INFO) : this(engine, null, configurationYAML, logLevel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import io.envoyproxy.envoymobile.engine.EnvoyEngine
import io.envoyproxy.envoymobile.engine.EnvoyEngineImpl


open class EnvoyBuilder internal constructor(
open class EnvoyClientBuilder internal constructor(
) {
private var logLevel = LogLevel.INFO
private var configYAML: String? = null
Expand All @@ -19,7 +19,7 @@ open class EnvoyBuilder internal constructor(
* Add a log level to use with Envoy.
* @param logLevel the log level to use with Envoy.
*/
fun addLogLevel(logLevel: LogLevel): EnvoyBuilder {
fun addLogLevel(logLevel: LogLevel): EnvoyClientBuilder {
this.logLevel = logLevel
return this
}
Expand All @@ -30,7 +30,7 @@ open class EnvoyBuilder internal constructor(
*
* @param configYAML the contents of a yaml file to use as a configuration.
*/
fun addConfigYAML(configYAML: String?): EnvoyBuilder {
fun addConfigYAML(configYAML: String?): EnvoyClientBuilder {
this.configYAML = configYAML
return this
}
Expand All @@ -40,7 +40,7 @@ open class EnvoyBuilder internal constructor(
*
* @param connectTimeoutSeconds timeout for new network connections to hosts in the cluster.
*/
fun addConnectTimeoutSeconds(connectTimeoutSeconds: Int): EnvoyBuilder {
fun addConnectTimeoutSeconds(connectTimeoutSeconds: Int): EnvoyClientBuilder {
this.connectTimeoutSeconds = connectTimeoutSeconds
return this
}
Expand All @@ -50,7 +50,7 @@ open class EnvoyBuilder internal constructor(
*
* @param dnsRefreshSeconds rate in seconds to refresh DNS.
*/
fun addDNSRefreshSeconds(dnsRefreshSeconds: Int): EnvoyBuilder {
fun addDNSRefreshSeconds(dnsRefreshSeconds: Int): EnvoyClientBuilder {
this.dnsRefreshSeconds = dnsRefreshSeconds
return this
}
Expand All @@ -60,7 +60,7 @@ open class EnvoyBuilder internal constructor(
*
* @param statsFlushSeconds interval at which to flush Envoy stats.
*/
fun addStatsFlushSeconds(statsFlushSeconds: Int): EnvoyBuilder {
fun addStatsFlushSeconds(statsFlushSeconds: Int): EnvoyClientBuilder {
this.statsFlushSeconds = statsFlushSeconds
return this
}
Expand All @@ -84,7 +84,7 @@ open class EnvoyBuilder internal constructor(
*
* A new instance of this engine will be created when `build()` is called.
*/
internal fun addEngineType(engineType: () -> EnvoyEngine): EnvoyBuilder {
internal fun addEngineType(engineType: () -> EnvoyEngine): EnvoyClientBuilder {
this.engineType = engineType
return this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.envoyproxy.envoymobile

import java.nio.ByteBuffer

interface Client {
interface HTTPClient {
/**
* For starting a stream.
*
Expand Down
6 changes: 3 additions & 3 deletions library/kotlin/test/io/envoyproxy/envoymobile/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ envoy_mobile_kt_test(
)

envoy_mobile_kt_test(
name = "envoy_builder_test",
name = "envoy_client_builder_test",
srcs = [
"EnvoyBuilderTest.kt",
"EnvoyClientBuilderTest.kt",
],
deps = [
"//library/kotlin/src/io/envoyproxy/envoymobile:envoy_interfaces_lib",
Expand All @@ -65,7 +65,7 @@ envoy_mobile_kt_test(
envoy_mobile_kt_test(
name = "envoy_client_test",
srcs = [
"EnvoyTest.kt",
"EnvoyClientTest.kt",
],
deps = [
"//library/kotlin/src/io/envoyproxy/envoymobile:envoy_interfaces_lib",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.envoyproxy.envoymobile.io.envoyproxy.envoymobile

import io.envoyproxy.envoymobile.EnvoyBuilder
import io.envoyproxy.envoymobile.EnvoyClientBuilder
import io.envoyproxy.envoymobile.LogLevel
import io.envoyproxy.envoymobile.engine.EnvoyEngine
import org.assertj.core.api.Assertions.assertThat
Expand All @@ -17,60 +17,60 @@ mock_template:

class EnvoyBuilderTest {

private lateinit var builder: EnvoyBuilder
private lateinit var clientBuilder: EnvoyClientBuilder

private var engine: EnvoyEngine = mock(EnvoyEngine::class.java)

@Test
fun `adding custom config builder uses custom config for running Envoy`() {
builder = EnvoyBuilder()
builder.addConfigYAML(TEST_CONFIG)
builder.addEngineType { engine }
clientBuilder = EnvoyClientBuilder()
clientBuilder.addConfigYAML(TEST_CONFIG)
clientBuilder.addEngineType { engine }

builder.addConfigYAML("mock_template:")
val envoy = builder.build()
clientBuilder.addConfigYAML("mock_template:")
val envoy = clientBuilder.build()
assertThat(envoy.configurationYAML).isEqualTo("mock_template:")
}

@Test
fun `adding log level builder uses log level for running Envoy`() {
builder = EnvoyBuilder()
builder.addConfigYAML(TEST_CONFIG)
builder.addEngineType { engine }
clientBuilder = EnvoyClientBuilder()
clientBuilder.addConfigYAML(TEST_CONFIG)
clientBuilder.addEngineType { engine }

builder.addLogLevel(LogLevel.DEBUG)
val envoy = builder.build()
clientBuilder.addLogLevel(LogLevel.DEBUG)
val envoy = clientBuilder.build()
assertThat(envoy.logLevel).isEqualTo(LogLevel.DEBUG)
}

@Test
fun `specifying connection timeout overrides default`() {
builder = EnvoyBuilder()
builder.addEngineType { engine }
clientBuilder = EnvoyClientBuilder()
clientBuilder.addEngineType { engine }

builder.addConnectTimeoutSeconds(1234)
val envoy = builder.build()
clientBuilder.addConnectTimeoutSeconds(1234)
val envoy = clientBuilder.build()
assertThat(envoy.envoyConfiguration!!.connectTimeoutSeconds).isEqualTo(1234)
}

@Test
fun `specifying DNS refresh overrides default`() {
builder = EnvoyBuilder()
builder.addEngineType { engine }
clientBuilder = EnvoyClientBuilder()
clientBuilder.addEngineType { engine }

builder.addDNSRefreshSeconds(1234)
val envoy = builder.build()
clientBuilder.addDNSRefreshSeconds(1234)
val envoy = clientBuilder.build()
assertThat(envoy.envoyConfiguration!!.dnsRefreshSeconds).isEqualTo(1234)
}

@Test
fun `specifying stats flush overrides default`() {
builder = EnvoyBuilder()
builder.addEngineType { engine }
clientBuilder = EnvoyClientBuilder()
clientBuilder.addEngineType { engine }

builder.addStatsFlushSeconds(1234)
builder.build()
val envoy = builder.build()
clientBuilder.addStatsFlushSeconds(1234)
clientBuilder.build()
val envoy = clientBuilder.build()
assertThat(envoy.envoyConfiguration!!.statsFlushSeconds).isEqualTo(1234)

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import org.mockito.Mockito.verify
import java.nio.ByteBuffer
import java.util.concurrent.Executor

class EnvoyTest {
class EnvoyClientTest {

private val engine = mock(EnvoyEngine::class.java)
private val stream = mock(EnvoyHTTPStream::class.java)
Expand Down