Skip to content

Commit 077655b

Browse files
authored
Revert "Callback to receive raw response body from featurevisor data request" (#29)
1 parent 6e851dd commit 077655b

File tree

4 files changed

+3
-12
lines changed

4 files changed

+3
-12
lines changed

src/main/kotlin/com/featurevisor/sdk/Instance+Fetch.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,18 @@ import java.lang.IllegalArgumentException
1313
internal fun FeaturevisorInstance.fetchDatafileContent(
1414
url: String,
1515
handleDatafileFetch: DatafileFetchHandler? = null,
16-
rawResponseReady: (ResponseBody) -> Unit,
1716
completion: (Result<DatafileContent>) -> Unit,
1817
) {
1918
handleDatafileFetch?.let { handleFetch ->
2019
val result = handleFetch(url)
2120
completion(result)
2221
} ?: run {
23-
fetchDatafileContentFromUrl(url, rawResponseReady, completion)
22+
fetchDatafileContentFromUrl(url, completion)
2423
}
2524
}
2625

2726
private fun fetchDatafileContentFromUrl(
2827
url: String,
29-
rawResponseReady: (ResponseBody) -> Unit,
3028
completion: (Result<DatafileContent>) -> Unit,
3129
) {
3230
try {
@@ -36,7 +34,7 @@ private fun fetchDatafileContentFromUrl(
3634
.addHeader("Content-Type", "application/json")
3735
.build()
3836

39-
fetch(request, rawResponseReady, completion)
37+
fetch(request, completion)
4038
} catch (throwable: IllegalArgumentException) {
4139
completion(Result.failure(FeaturevisorError.InvalidUrl(url)))
4240
}
@@ -45,15 +43,13 @@ private fun fetchDatafileContentFromUrl(
4543
const val BODY_BYTE_COUNT = 1000000L
4644
private inline fun fetch(
4745
request: Request,
48-
crossinline rawResponseReady: (ResponseBody) -> Unit,
4946
crossinline completion: (Result<DatafileContent>) -> Unit,
5047
) {
5148
val client = OkHttpClient()
5249
val call = client.newCall(request)
5350
call.enqueue(object : Callback {
5451
override fun onResponse(call: Call, response: Response) {
5552
val responseBody = response.peekBody(BODY_BYTE_COUNT)
56-
rawResponseReady(responseBody)
5753
if (response.isSuccessful) {
5854
val json = Json {
5955
ignoreUnknownKeys = true

src/main/kotlin/com/featurevisor/sdk/Instance+Refresh.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ private fun FeaturevisorInstance.refresh() {
4242
fetchDatafileContent(
4343
datafileUrl,
4444
handleDatafileFetch,
45-
rawResponseReady,
4645
) { result ->
4746

4847
if (result.isSuccess) {

src/main/kotlin/com/featurevisor/sdk/Instance.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import com.featurevisor.types.EventName.*
99
import kotlinx.coroutines.Job
1010
import kotlinx.serialization.decodeFromString
1111
import kotlinx.serialization.json.Json
12-
import okhttp3.ResponseBody
1312

1413
typealias ConfigureBucketKey = (Feature, Context, BucketKey) -> BucketKey
1514
typealias ConfigureBucketValue = (Feature, Context, BucketValue) -> BucketValue
@@ -57,7 +56,6 @@ class FeaturevisorInstance private constructor(options: InstanceOptions) {
5756
internal var configureBucketKey = options.configureBucketKey
5857
internal var configureBucketValue = options.configureBucketValue
5958
internal var refreshJob: Job? = null
60-
internal var rawResponseReady: (ResponseBody) -> Unit = options.rawResponseReady
6159

6260
init {
6361
with(options) {
@@ -102,7 +100,7 @@ class FeaturevisorInstance private constructor(options: InstanceOptions) {
102100

103101
datafileUrl != null -> {
104102
datafileReader = DatafileReader(options.datafile?: emptyDatafile)
105-
fetchDatafileContent(datafileUrl, handleDatafileFetch, rawResponseReady) { result ->
103+
fetchDatafileContent(datafileUrl, handleDatafileFetch) { result ->
106104
if (result.isSuccess) {
107105
datafileReader = DatafileReader(result.getOrThrow())
108106
statuses.ready = true

src/main/kotlin/com/featurevisor/sdk/InstanceOptions.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.featurevisor.sdk
33
import com.featurevisor.types.DatafileContent
44
import com.featurevisor.types.InitialFeatures
55
import com.featurevisor.types.StickyFeatures
6-
import okhttp3.ResponseBody
76

87
typealias Listener = (Array<out Any>) -> Unit
98

@@ -24,7 +23,6 @@ data class InstanceOptions(
2423
val onError: Listener? = null,
2524
val refreshInterval: Long? = null, // seconds
2625
val stickyFeatures: StickyFeatures? = null,
27-
val rawResponseReady: (ResponseBody) -> Unit = {},
2826
) {
2927
companion object {
3028
private const val defaultBucketKeySeparator = "."

0 commit comments

Comments
 (0)