Skip to content

Commit

Permalink
chore: Publish v6.0.0-SNAPSHOT
Browse files Browse the repository at this point in the history
  • Loading branch information
anssari1 authored and github-actions[bot] committed Jan 15, 2025
1 parent c338b10 commit cd3d678
Show file tree
Hide file tree
Showing 28 changed files with 86 additions and 286 deletions.
2 changes: 1 addition & 1 deletion code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<dependency>
<groupId>com.expediagroup</groupId>
<artifactId>rapid-sdk</artifactId>
<version>5.3.0</version>
<version>6.0.0-SNAPSHOT</version>
</dependency>
```

Expand Down
14 changes: 7 additions & 7 deletions code/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.expediagroup</groupId>
<artifactId>rapid-sdk</artifactId>
<version>5.3.0</version>
<version>6.0.0-SNAPSHOT</version>
<name>EG rapid-sdk for Java</name>
<description>EG rapid-sdk v5.3.0</description>
<description>EG rapid-sdk v6.0.0-SNAPSHOT</description>
<url>https://github.com/ExpediaGroup/test-sdk</url>
<inceptionYear>2022</inceptionYear>
<packaging>jar</packaging>
Expand Down Expand Up @@ -81,7 +81,7 @@
<flatten.maven.plugin.version>1.6.0</flatten.maven.plugin.version>
<kotlin.version>2.0.21</kotlin.version>
<kotlinx.coroutines.version>1.9.0</kotlinx.coroutines.version>
<ktor.version>2.3.13</ktor.version>
<ktor.version>3.0.3</ktor.version>
<kotlin-atomic.version>0.26.1</kotlin-atomic.version>
<slf4j.version>2.0.16</slf4j.version>
<maven.nexus-staging.plugin.version>1.7.0</maven.nexus-staging.plugin.version>
Expand Down Expand Up @@ -732,25 +732,25 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<version>3.17.0</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.12.0</version>
<version>1.13.0</version>
</dependency>

<dependency>
<groupId>com.ebay.ejmask</groupId>
<artifactId>ejmask-api</artifactId>
<version>1.2.1</version>
<version>1.3.0</version>
</dependency>

<dependency>
<groupId>com.ebay.ejmask</groupId>
<artifactId>ejmask-extensions</artifactId>
<version>1.2.1</version>
<version>1.3.0</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ abstract class BaseRapidClient(
private val engine: HttpClientEngine =
_configurationProvider.okHttpClient?.let {
OkHttp.create {
preconfigured = it
config {
preconfigured = it
dispatcher(it.dispatcher)
}
}
} ?: httpClientEngine

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ abstract class BaseXapClient(
private val engine: HttpClientEngine =
_configurationProvider.okHttpClient?.let {
OkHttp.create {
preconfigured = it
config {
preconfigured = it
dispatcher(it.dispatcher)
}
}
} ?: httpClientEngine

Expand Down
22 changes: 3 additions & 19 deletions code/src/main/kotlin/com/expediagroup/sdk/core/client/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import okhttp3.Dispatcher
import okhttp3.OkHttpClient

// Create a Dispatcher with limits
val dispatcher =
val configuredDispatcher =
Dispatcher().apply {
maxRequests = 10000 // Maximum number of concurrent requests
maxRequestsPerHost = 1000
Expand All @@ -64,7 +64,7 @@ val DEFAULT_HTTP_CLIENT_ENGINE: HttpClientEngine =
OkHttp.create {
config {
eventListenerFactory(OkHttpEventListener.FACTORY)
dispatcher(dispatcher)
dispatcher(configuredDispatcher)
}
}

Expand Down Expand Up @@ -103,7 +103,6 @@ abstract class Client(
val connectionTimeout: Long = configurationProvider.connectionTimeout ?: fireMissingConfigurationIssue(ConfigurationName.CONNECTION_TIMEOUT_MILLIS)
val socketTimeout: Long = configurationProvider.socketTimeout ?: fireMissingConfigurationIssue(ConfigurationName.SOCKET_TIMEOUT_MILLIS)
val maskedLoggingHeaders: Set<String> = configurationProvider.maskedLoggingHeaders ?: setOf()
val maskedLoggingBodyFields: Set<String> = configurationProvider.maskedLoggingBodyFields ?: setOf()

val authenticationConfiguration =
AuthenticationConfiguration.from(
Expand All @@ -114,7 +113,7 @@ abstract class Client(
)

plugins {
use(LoggingPlugin).with(LoggingConfiguration.from(httpClientConfig, maskedLoggingHeaders, maskedLoggingBodyFields))
use(LoggingPlugin).with(LoggingConfiguration.from(httpClientConfig, maskedLoggingHeaders))
use(SerializationPlugin).with(SerializationConfiguration.from(httpClientConfig))
use(AuthenticationPlugin).with(authenticationConfiguration)
use(DefaultRequestPlugin).with(DefaultRequestConfiguration.from(httpClientConfig, endpoint))
Expand Down Expand Up @@ -164,9 +163,6 @@ abstract class Client(
/** Sets tne body fields to be masked in logging. */
protected var maskedLoggingHeaders: Set<String>? = null

/** Sets tne body fields to be masked in logging. */
protected var maskedLoggingBodyFields: Set<String>? = null

/** Sets the API key to use for authentication.
*
* @param key The API key to use for authentication.
Expand Down Expand Up @@ -210,18 +206,6 @@ abstract class Client(
return self()
}

/**
* Sets tne body fields to be masked in logging.
*
* @param fields the body fields to be masked in logging.
* @return The [Builder] instance.
*/
fun maskedLoggingBodyFields(vararg fields: String): SELF {
this.maskedLoggingBodyFields = fields.toSet()
log.info(LoggingMessageProvider.getRuntimeConfigurationProviderMessage(ConfigurationName.MASKED_LOGGING_BODY_FIELDS, fields.joinToString()))
return self()
}

/** Create a [Client] object. */
abstract fun build(): Client

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,20 @@ abstract class ExpediaGroupClient(
return self()
}
}

@Suppress("unused", "UnnecessaryAbstractClass") // This is used by the generated SDK clients.
abstract class BuilderWithHttpClient<SELF : Client.BuilderWithHttpClient<SELF>> : Client.BuilderWithHttpClient<SELF>() {
/** Sets the API auth endpoint to use for requests. */
protected var authEndpoint: String? = null

/** Sets the API auth endpoint to use for requests.
*
* @param authEndpoint The API auth endpoint to use for requests.
* @return The [Builder] instance.
*/
fun authEndpoint(authEndpoint: String): SELF {
this.authEndpoint = authEndpoint
return self()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ interface ClientConfiguration {
val connectionTimeout: Long?
val socketTimeout: Long?
val maskedLoggingHeaders: Set<String>?
val maskedLoggingBodyFields: Set<String>?
val okHttpClient: OkHttpClient?

/** Build a [RuntimeConfigurationProvider] from a [ClientConfiguration]. */
Expand All @@ -39,7 +38,6 @@ interface ClientConfiguration {
connectionTimeout = connectionTimeout,
socketTimeout = socketTimeout,
maskedLoggingHeaders = maskedLoggingHeaders,
maskedLoggingBodyFields = maskedLoggingBodyFields,
okHttpClient = okHttpClient
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import okhttp3.OkHttpClient
* @property connectionTimeout The connection timeout to be used in milliseconds.
* @property socketTimeout The socket timeout to be used in milliseconds.
* @property maskedLoggingHeaders The headers to be masked in logging.
* @property maskedLoggingBodyFields The body fields to be masked in logging.
* @property authEndpoint The API endpoint to use for authentication.
* @property okHttpClient The okhttp client to be used by the sdk.
*/
Expand All @@ -41,7 +40,6 @@ data class ExpediaGroupClientConfiguration(
override val connectionTimeout: Long? = null,
override val socketTimeout: Long? = null,
override val maskedLoggingHeaders: Set<String>? = null,
override val maskedLoggingBodyFields: Set<String>? = null,
override val okHttpClient: OkHttpClient? = null,
val authEndpoint: String? = null
) : ClientConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import okhttp3.OkHttpClient
* @property connectionTimeout The connection timeout to be used in milliseconds.
* @property socketTimeout The socket timeout to be used in milliseconds.
* @property maskedLoggingHeaders The headers to be masked in logging.
* @property maskedLoggingBodyFields The body fields to be masked in logging.
*/
data class RapidClientConfiguration(
override val key: String? = null,
Expand All @@ -38,6 +37,5 @@ data class RapidClientConfiguration(
override val connectionTimeout: Long? = null,
override val socketTimeout: Long? = null,
override val maskedLoggingHeaders: Set<String>? = null,
override val maskedLoggingBodyFields: Set<String>? = null,
override val okHttpClient: OkHttpClient? = null
) : ClientConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import okhttp3.OkHttpClient
* @property connectionTimeout The connection timeout to be used in milliseconds.
* @property socketTimeout The socket timeout to be used in milliseconds.
* @property maskedLoggingHeaders The headers to be masked in logging.
* @property maskedLoggingBodyFields The body fields to be masked in logging.
*/
data class XapClientConfiguration(
override val key: String? = null,
Expand All @@ -38,6 +37,5 @@ data class XapClientConfiguration(
override val connectionTimeout: Long? = null,
override val socketTimeout: Long? = null,
override val maskedLoggingHeaders: Set<String>? = null,
override val maskedLoggingBodyFields: Set<String>? = null,
override val okHttpClient: OkHttpClient? = null
) : ClientConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import com.expediagroup.sdk.core.constant.ConfigurationName.CONFIGURATION_COLLEC
import com.expediagroup.sdk.core.constant.ConfigurationName.CONNECTION_TIMEOUT_MILLIS
import com.expediagroup.sdk.core.constant.ConfigurationName.ENDPOINT
import com.expediagroup.sdk.core.constant.ConfigurationName.KEY
import com.expediagroup.sdk.core.constant.ConfigurationName.MASKED_LOGGING_BODY_FIELDS
import com.expediagroup.sdk.core.constant.ConfigurationName.MASKED_LOGGING_HEADERS
import com.expediagroup.sdk.core.constant.ConfigurationName.REQUEST_TIMEOUT_MILLIS
import com.expediagroup.sdk.core.constant.ConfigurationName.SECRET
Expand Down Expand Up @@ -66,7 +65,6 @@ internal class ConfigurationCollector private constructor(providers: Configurati
override val connectionTimeout: Long? = providers.firstWith { it.connectionTimeout }.also { it?.log(CONNECTION_TIMEOUT_MILLIS) }?.retrieve()
override val socketTimeout: Long? = providers.firstWith { it.socketTimeout }.also { it?.log(SOCKET_TIMEOUT_MILLIS) }?.retrieve()
override val maskedLoggingHeaders: Set<String>? = providers.firstWith { it.maskedLoggingHeaders }.also { it?.log(MASKED_LOGGING_HEADERS) }?.retrieve()
override val maskedLoggingBodyFields: Set<String>? = providers.firstWith { it.maskedLoggingBodyFields }.also { it?.log(MASKED_LOGGING_BODY_FIELDS) }?.retrieve()
override val okHttpClient: OkHttpClient? = providers.firstWith { it.okHttpClient }?.retrieve()

private fun <T> ProvidedConfiguration<T>.log(configurationName: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ interface ConfigurationProvider {
val maskedLoggingHeaders: Set<String>?
get() = setOf()

/** The body fields to be masked in logging.*/
val maskedLoggingBodyFields: Set<String>?
get() = setOf()

/** The okhttp client to be used by the sdk.*/
val okHttpClient: OkHttpClient?
get() = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import okhttp3.OkHttpClient
* @property connectionTimeout The connection timeout to be used in milliseconds.
* @property socketTimeout The socket timeout to be used in milliseconds.
* @property maskedLoggingHeaders The headers to be masked in logging.
* @property maskedLoggingBodyFields The body fields to be masked in logging.
*/
data class RuntimeConfigurationProvider(
override val name: String = RUNTIME_CONFIGURATION_PROVIDER,
Expand All @@ -42,6 +41,5 @@ data class RuntimeConfigurationProvider(
override val connectionTimeout: Long? = null,
override val socketTimeout: Long? = null,
override val maskedLoggingHeaders: Set<String>? = null,
override val maskedLoggingBodyFields: Set<String>? = null,
override val okHttpClient: OkHttpClient? = null
) : ConfigurationProvider
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
*/
package com.expediagroup.sdk.core.configuration.provider

import com.expediagroup.sdk.core.configuration.provider.RapidConfigurationProvider.connectionTimeout
import com.expediagroup.sdk.core.configuration.provider.RapidConfigurationProvider.endpoint
import com.expediagroup.sdk.core.configuration.provider.RapidConfigurationProvider.name
import com.expediagroup.sdk.core.configuration.provider.RapidConfigurationProvider.requestTimeout
import com.expediagroup.sdk.core.configuration.provider.RapidConfigurationProvider.socketTimeout
import com.expediagroup.sdk.core.constant.Constant

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
*/
package com.expediagroup.sdk.core.constant

import io.ktor.client.plugins.HttpTimeout
import io.ktor.client.plugins.HttpTimeoutConfig

internal object Constant {
const val EMPTY_STRING = ""
const val TEN_SECONDS_IN_MILLIS = 10_000L
const val FIFTEEN_SECONDS_IN_MILLIS = 15_000L
const val INFINITE_TIMEOUT = HttpTimeout.INFINITE_TIMEOUT_MS
const val INFINITE_TIMEOUT = HttpTimeoutConfig.INFINITE_TIMEOUT_MS

private const val SUCCESSFUL_STATUS_CODES_RANGE_START = 200
private const val SUCCESSFUL_STATUS_CODES_RANGE_END = 299
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import io.ktor.client.statement.HttpResponse
sealed class BasePaginator<R, T>(
private val client: Client,
firstResponse: Response<T>,
private val fallbackBody: T,
private val getBody: suspend (HttpResponse) -> T
) : Iterator<R> {
private var state: ResponseState<T> = DefaultResponseState(firstResponse)
Expand All @@ -41,7 +40,7 @@ sealed class BasePaginator<R, T>(

protected fun nextResponse(): Response<T> {
val response = state.getNextResponse()
state = ResponseStateFactory.getState(extractLink(response.headers), client, fallbackBody, getBody)
state = ResponseStateFactory.getState(extractLink(response.headers), client, getBody)
return response
}
}
Expand All @@ -56,9 +55,8 @@ sealed class BasePaginator<R, T>(
class Paginator<T>(
client: Client,
firstResponse: Response<T>,
fallbackBody: T,
getBody: suspend (HttpResponse) -> T
) : BasePaginator<T, T>(client, firstResponse, fallbackBody, getBody) {
) : BasePaginator<T, T>(client, firstResponse, getBody) {
/**
* Returns the body of the next response.
*
Expand All @@ -77,9 +75,8 @@ class Paginator<T>(
class ResponsePaginator<T>(
client: Client,
firstResponse: Response<T>,
fallbackBody: T,
getBody: suspend (HttpResponse) -> T
) : BasePaginator<Response<T>, T>(client, firstResponse, fallbackBody, getBody) {
) : BasePaginator<Response<T>, T>(client, firstResponse, getBody) {
/**
* Returns the next response.
*
Expand Down
Loading

0 comments on commit cd3d678

Please sign in to comment.