Skip to content

Commit 97b8b21

Browse files
chore(internal): version bump
1 parent d0b09b8 commit 97b8b21

File tree

127 files changed

+1889
-232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+1889
-232
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@ on:
77
- 'integrated/**'
88
- 'stl-preview-head/**'
99
- 'stl-preview-base/**'
10+
pull_request:
11+
branches-ignore:
12+
- 'stl-preview-head/**'
13+
- 'stl-preview-base/**'
1014

1115
jobs:
1216
lint:
1317
timeout-minutes: 10
1418
name: lint
1519
runs-on: ${{ github.repository == 'stainless-sdks/open-transit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
20+
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
1621

1722
steps:
1823
- uses: actions/checkout@v4
@@ -35,6 +40,7 @@ jobs:
3540
timeout-minutes: 10
3641
name: test
3742
runs-on: ${{ github.repository == 'stainless-sdks/open-transit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
43+
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
3844
steps:
3945
- uses: actions/checkout@v4
4046

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ See this table for the available options:
106106
> Don't create more than one client in the same application. Each client has a connection pool and
107107
> thread pools, which are more efficient to share between requests.
108108
109+
### Modifying configuration
110+
111+
To temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:
112+
113+
```java
114+
import org.onebusaway.client.OnebusawaySdkClient;
115+
116+
OnebusawaySdkClient clientWithOptions = client.withOptions(optionsBuilder -> {
117+
optionsBuilder.baseUrl("https://example.com");
118+
optionsBuilder.maxRetries(42);
119+
});
120+
```
121+
122+
The `withOptions()` method does not affect the original client or service.
123+
109124
## Requests and responses
110125

111126
To send a request to the Onebusaway SDK API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.

SECURITY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ before making any information public.
1616
## Reporting Non-SDK Related Security Issues
1717

1818
If you encounter security issues that are not directly related to SDKs but pertain to the services
19-
or products provided by Onebusaway SDK please follow the respective company's security reporting guidelines.
19+
or products provided by Onebusaway SDK, please follow the respective company's security reporting guidelines.
2020

2121
### Onebusaway SDK Terms and Policies
2222

23-
Please contact [email protected] for any questions or concerns regarding security of our services.
23+
Please contact [email protected] for any questions or concerns regarding the security of our services.
2424

2525
---
2626

bin/check-release-environment

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
errors=()
44

55
if [ -z "${SONATYPE_USERNAME}" ]; then
6-
errors+=("The ONEBUSAWAY_SDK_SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets")
6+
errors+=("The SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets")
77
fi
88

99
if [ -z "${SONATYPE_PASSWORD}" ]; then
10-
errors+=("The ONEBUSAWAY_SDK_SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets")
10+
errors+=("The SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets")
1111
fi
1212

1313
if [ -z "${GPG_SIGNING_KEY}" ]; then
14-
errors+=("The ONEBUSAWAY_SDK_SONATYPE_GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets")
14+
errors+=("The GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets")
1515
fi
1616

1717
if [ -z "${GPG_SIGNING_PASSWORD}" ]; then
18-
errors+=("The ONEBUSAWAY_SDK_SONATYPE_GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets")
18+
errors+=("The GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets")
1919
fi
2020

2121
lenErrors=${#errors[@]}

onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import java.time.Duration
77
import java.util.concurrent.CompletableFuture
88
import okhttp3.Call
99
import okhttp3.Callback
10-
import okhttp3.HttpUrl
1110
import okhttp3.HttpUrl.Companion.toHttpUrl
1211
import okhttp3.Interceptor
1312
import okhttp3.MediaType
@@ -20,7 +19,6 @@ import okhttp3.logging.HttpLoggingInterceptor
2019
import okio.BufferedSink
2120
import org.onebusaway.core.RequestOptions
2221
import org.onebusaway.core.Timeout
23-
import org.onebusaway.core.checkRequired
2422
import org.onebusaway.core.http.Headers
2523
import org.onebusaway.core.http.HttpClient
2624
import org.onebusaway.core.http.HttpMethod
@@ -29,8 +27,7 @@ import org.onebusaway.core.http.HttpRequestBody
2927
import org.onebusaway.core.http.HttpResponse
3028
import org.onebusaway.errors.OnebusawaySdkIoException
3129

32-
class OkHttpClient
33-
private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) :
30+
class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) :
3431
HttpClient {
3532

3633
override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse {
@@ -142,11 +139,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
142139
}
143140

144141
private fun HttpRequest.toUrl(): String {
145-
url?.let {
146-
return it
147-
}
148-
149-
val builder = baseUrl.newBuilder()
142+
val builder = baseUrl.toHttpUrl().newBuilder()
150143
pathSegments.forEach(builder::addPathSegment)
151144
queryParams.keys().forEach { key ->
152145
queryParams.values(key).forEach { builder.addQueryParameter(key, it) }
@@ -196,12 +189,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
196189

197190
class Builder internal constructor() {
198191

199-
private var baseUrl: HttpUrl? = null
200192
private var timeout: Timeout = Timeout.default()
201193
private var proxy: Proxy? = null
202194

203-
fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl.toHttpUrl() }
204-
205195
fun timeout(timeout: Timeout) = apply { this.timeout = timeout }
206196

207197
fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build())
@@ -216,8 +206,12 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
216206
.writeTimeout(timeout.write())
217207
.callTimeout(timeout.request())
218208
.proxy(proxy)
219-
.build(),
220-
checkRequired("baseUrl", baseUrl),
209+
.build()
210+
.apply {
211+
// We usually make all our requests to the same host so it makes sense to
212+
// raise the per-host limit to the overall limit.
213+
dispatcher.maxRequestsPerHost = dispatcher.maxRequests
214+
}
221215
)
222216
}
223217
}

onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,7 @@ class OnebusawaySdkOkHttpClient private constructor() {
163163
fun build(): OnebusawaySdkClient =
164164
OnebusawaySdkClientImpl(
165165
clientOptions
166-
.httpClient(
167-
OkHttpClient.builder()
168-
.baseUrl(clientOptions.baseUrl())
169-
.timeout(timeout)
170-
.proxy(proxy)
171-
.build()
172-
)
166+
.httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build())
173167
.build()
174168
)
175169
}

onebusaway-sdk-java-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,7 @@ class OnebusawaySdkOkHttpClientAsync private constructor() {
164164
fun build(): OnebusawaySdkClientAsync =
165165
OnebusawaySdkClientAsyncImpl(
166166
clientOptions
167-
.httpClient(
168-
OkHttpClient.builder()
169-
.baseUrl(clientOptions.baseUrl())
170-
.timeout(timeout)
171-
.proxy(proxy)
172-
.build()
173-
)
167+
.httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build())
174168
.build()
175169
)
176170
}

onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClient.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
package org.onebusaway.client
44

5+
import java.util.function.Consumer
6+
import org.onebusaway.core.ClientOptions
57
import org.onebusaway.services.blocking.AgenciesWithCoverageService
68
import org.onebusaway.services.blocking.AgencyService
79
import org.onebusaway.services.blocking.ArrivalAndDepartureService
@@ -60,6 +62,13 @@ interface OnebusawaySdkClient {
6062
*/
6163
fun withRawResponse(): WithRawResponse
6264

65+
/**
66+
* Returns a view of this service with the given option modifications applied.
67+
*
68+
* The original service is not modified.
69+
*/
70+
fun withOptions(modifier: Consumer<ClientOptions.Builder>): OnebusawaySdkClient
71+
6372
fun agenciesWithCoverage(): AgenciesWithCoverageService
6473

6574
fun agency(): AgencyService
@@ -134,6 +143,15 @@ interface OnebusawaySdkClient {
134143
*/
135144
interface WithRawResponse {
136145

146+
/**
147+
* Returns a view of this service with the given option modifications applied.
148+
*
149+
* The original service is not modified.
150+
*/
151+
fun withOptions(
152+
modifier: Consumer<ClientOptions.Builder>
153+
): OnebusawaySdkClient.WithRawResponse
154+
137155
fun agenciesWithCoverage(): AgenciesWithCoverageService.WithRawResponse
138156

139157
fun agency(): AgencyService.WithRawResponse

onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsync.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
package org.onebusaway.client
44

5+
import java.util.function.Consumer
6+
import org.onebusaway.core.ClientOptions
57
import org.onebusaway.services.async.AgenciesWithCoverageServiceAsync
68
import org.onebusaway.services.async.AgencyServiceAsync
79
import org.onebusaway.services.async.ArrivalAndDepartureServiceAsync
@@ -60,6 +62,13 @@ interface OnebusawaySdkClientAsync {
6062
*/
6163
fun withRawResponse(): WithRawResponse
6264

65+
/**
66+
* Returns a view of this service with the given option modifications applied.
67+
*
68+
* The original service is not modified.
69+
*/
70+
fun withOptions(modifier: Consumer<ClientOptions.Builder>): OnebusawaySdkClientAsync
71+
6372
fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync
6473

6574
fun agency(): AgencyServiceAsync
@@ -135,6 +144,15 @@ interface OnebusawaySdkClientAsync {
135144
*/
136145
interface WithRawResponse {
137146

147+
/**
148+
* Returns a view of this service with the given option modifications applied.
149+
*
150+
* The original service is not modified.
151+
*/
152+
fun withOptions(
153+
modifier: Consumer<ClientOptions.Builder>
154+
): OnebusawaySdkClientAsync.WithRawResponse
155+
138156
fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync.WithRawResponse
139157

140158
fun agency(): AgencyServiceAsync.WithRawResponse

onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
package org.onebusaway.client
44

5+
import java.util.function.Consumer
56
import org.onebusaway.core.ClientOptions
67
import org.onebusaway.core.getPackageVersion
78
import org.onebusaway.services.async.AgenciesWithCoverageServiceAsync
@@ -191,6 +192,9 @@ class OnebusawaySdkClientAsyncImpl(private val clientOptions: ClientOptions) :
191192

192193
override fun withRawResponse(): OnebusawaySdkClientAsync.WithRawResponse = withRawResponse
193194

195+
override fun withOptions(modifier: Consumer<ClientOptions.Builder>): OnebusawaySdkClientAsync =
196+
OnebusawaySdkClientAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build())
197+
194198
override fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync = agenciesWithCoverage
195199

196200
override fun agency(): AgencyServiceAsync = agency
@@ -366,6 +370,13 @@ class OnebusawaySdkClientAsyncImpl(private val clientOptions: ClientOptions) :
366370
ShapeServiceAsyncImpl.WithRawResponseImpl(clientOptions)
367371
}
368372

373+
override fun withOptions(
374+
modifier: Consumer<ClientOptions.Builder>
375+
): OnebusawaySdkClientAsync.WithRawResponse =
376+
OnebusawaySdkClientAsyncImpl.WithRawResponseImpl(
377+
clientOptions.toBuilder().apply(modifier::accept).build()
378+
)
379+
369380
override fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync.WithRawResponse =
370381
agenciesWithCoverage
371382

0 commit comments

Comments
 (0)