Skip to content

Commit

Permalink
revert "Move httpclient configuration into the config class"
Browse files Browse the repository at this point in the history
  • Loading branch information
Bdegraaf1234 committed Jun 12, 2024
1 parent 114edc1 commit a4be577
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
14 changes: 7 additions & 7 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@Suppress("ConstPropertyName", "MemberVisibilityCanBePrivate")
object Versions {
const val project = "1.1.3"
const val project = "1.1.2"

object Plugins {
const val licenseReport = "2.5"
Expand All @@ -14,17 +14,17 @@ object Versions {
}

const val java = 17
const val slf4j = "2.0.13"
const val confluent = "7.6.0"
const val kafka = "${confluent}-ce"
const val slf4j = "2.0.9"
const val confluent = "7.5.0"
const val kafka = "7.5.0-ce"
const val avro = "1.11.3"
const val jackson = "2.15.3"
const val okhttp = "4.12.0"
const val jackson = "2.15.2"
const val okhttp = "4.11.0"
const val junit = "5.10.0"
const val mockito = "5.5.0"
const val mockitoKotlin = "5.1.0"
const val hamcrest = "2.2"
const val radarSchemas = "0.8.8"
const val radarSchemas = "0.8.4"
const val opencsv = "5.8"
const val ktor = "2.3.4"
const val coroutines = "1.7.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package org.radarbase.producer.schema

import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.plugins.auth.*
import io.ktor.client.plugins.auth.providers.*
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.client.request.*
import io.ktor.client.plugins.defaultRequest
import io.ktor.client.request.HttpRequestBuilder
import io.ktor.client.request.accept
import io.ktor.client.request.request
import io.ktor.client.request.setBody
import io.ktor.client.request.url
import io.ktor.http.ContentType
import io.ktor.http.HttpMethod
import io.ktor.http.contentType
Expand All @@ -18,15 +21,13 @@ import kotlinx.coroutines.withContext
import kotlinx.serialization.json.Json
import org.apache.avro.Schema
import org.radarbase.producer.rest.RestException.Companion.toRestException
import org.slf4j.LoggerFactory
import java.io.IOException
import java.net.URI
import kotlin.coroutines.CoroutineContext

/** REST client for Confluent schema registry. */
class SchemaRestClient(
httpClient: HttpClient,
private val baseUrl: String,
baseUrl: String,
private val ioContext: CoroutineContext = Dispatchers.IO,
) {
private val httpClient: HttpClient = httpClient.config {
Expand All @@ -38,6 +39,10 @@ class SchemaRestClient(
},
)
}
defaultRequest {
url(baseUrl)
accept(ContentType.Application.Json)
}
}

suspend inline fun <reified T> request(
Expand Down Expand Up @@ -83,7 +88,7 @@ class SchemaRestClient(
@Throws(IOException::class)
suspend fun schemaGet(path: String): SchemaMetadata = request {
method = HttpMethod.Get
url(URI(baseUrl).resolve(path).toString())
url(path)
}

@Throws(IOException::class)
Expand All @@ -92,7 +97,7 @@ class SchemaRestClient(
schema: Schema,
): SchemaMetadata = request {
method = HttpMethod.Post
url(URI(baseUrl).resolve(path).toString())
url(path)
contentType(ContentType.Application.Json)
setBody(SchemaMetadata(schema = schema.toString()))
}
Expand Down Expand Up @@ -127,8 +132,4 @@ class SchemaRestClient(
schemaGet("/schemas/ids/$id")
.toParsedSchemaMetadata(id)
.schema

companion object {
private val logger = LoggerFactory.getLogger(SchemaRestClient::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ open class SchemaRetriever(config: Config) {
@RadarProducerDsl
class Config(
val baseUrl: String,
var httpClient: HttpClient? = null,
) {
var httpClient: HttpClient? = null
var schemaTimeout: CacheConfig = DEFAULT_SCHEMA_TIMEOUT_CONFIG
var ioContext: CoroutineContext = Dispatchers.IO
fun httpClient(config: HttpClientConfig<*>.() -> Unit) {
Expand Down

0 comments on commit a4be577

Please sign in to comment.