File tree Expand file tree Collapse file tree
impl/java/client/src/main/kotlin/br/com/guiabolso/events/client/http Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
77import kotlinx.coroutines.suspendCancellableCoroutine
88import okhttp3.Call
99import okhttp3.Callback
10+ import okhttp3.Dispatcher
1011import okhttp3.OkHttpClient
1112import okhttp3.Request
1213import okhttp3.RequestBody.Companion.toRequestBody
@@ -38,7 +39,9 @@ suspend fun Call.executeAsync(): Response =
3839 )
3940 }
4041
41- class OkHttpClientAdapter (private val okHttpClient : OkHttpClient = OkHttpClient .Builder ().build()) : HttpClientAdapter {
42+ class OkHttpClientAdapter (
43+ private val okHttpClient : OkHttpClient = okHttpClient()
44+ ) : HttpClientAdapter {
4245 private val clients = ConcurrentHashMap <Long , OkHttpClient >()
4346
4447 override suspend fun suspendPost (
@@ -119,3 +122,10 @@ class OkHttpClientAdapter(private val okHttpClient: OkHttpClient = OkHttpClient.
119122 }
120123 }
121124}
125+
126+ @Suppress(" MagicNumber" )
127+ private fun okHttpClient (): OkHttpClient = OkHttpClient .Builder ().dispatcher(
128+ Dispatcher ().apply {
129+ maxRequestsPerHost = 32
130+ }
131+ ).build()
You can’t perform that action at this time.
0 commit comments