File tree Expand file tree Collapse file tree 2 files changed +18
-7
lines changed
library/src/main/kotlin/com/gabrielfeo/gradle/enterprise/api Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -37,15 +37,16 @@ data class Config(
3737 },
3838
3939 /* *
40- * Provider of an [OkHttpClient.Builder] to use when building the library's internal client.
41- * Has a default value and shouldn't be needed in scripts.
40+ * [OkHttpClient.Builder] to use when building the library's internal [OkHttpClient].
4241 *
43- * This is aimed at using the library inside a full Kotlin project. Allows the internal client to
44- * share resources such as thread pools with another [OkHttpClient], useful for full Kotlin projects
45- * and rarely needed for scripting. See [OkHttpClient] for all that is shared.
42+ * This is aimed at using the library inside a full Kotlin project. Allows the internal client
43+ * to share resources such as thread pools with another [OkHttpClient]. See [OkHttpClient]
44+ * for all that is shared.
45+ *
46+ * The default is to share resources only within the library, i.e. multiple `Config()` with
47+ * the default [clientBuilder] will already share resources.
4648 */
47- val clientBuilder : OkHttpClient .Builder =
48- OkHttpClient .Builder (),
49+ val clientBuilder : OkHttpClient .Builder = basicOkHttpClient.newBuilder(),
4950
5051 /* *
5152 * Maximum amount of concurrent requests allowed. Further requests will be queued. By default,
Original file line number Diff line number Diff line change @@ -12,6 +12,16 @@ import java.time.Duration
1212import java.util.logging.Level
1313import java.util.logging.Logger
1414
15+ /* *
16+ * Base instance just so that multiple created [Config]s will share resources by default.
17+ */
18+ internal val basicOkHttpClient by lazy {
19+ OkHttpClient .Builder ().build()
20+ }
21+
22+ /* *
23+ * Builds the final `OkHttpClient` with a `Config`.
24+ */
1525internal fun buildOkHttpClient (
1626 config : Config ,
1727) = with (config.clientBuilder) {
You can’t perform that action at this time.
0 commit comments