Skip to content

Commit c12ac3e

Browse files
feat(client): add close method (#714)
1 parent 520c559 commit c12ac3e

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClient.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,17 @@ interface IncreaseClient {
171171
fun realTimePaymentsRequestForPayments(): RealTimePaymentsRequestForPaymentService
172172

173173
fun simulations(): SimulationService
174+
175+
/**
176+
* Closes this client, relinquishing any underlying resources.
177+
*
178+
* This is purposefully not inherited from [AutoCloseable] because the client is long-lived and
179+
* usually should not be synchronously closed via try-with-resources.
180+
*
181+
* It's also usually not necessary to call this method at all. the default HTTP client
182+
* automatically releases threads and connections if they remain idle, but if you are writing an
183+
* application that needs to aggressively release unused resources, then you may call this
184+
* method.
185+
*/
186+
fun close()
174187
}

increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsync.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,17 @@ interface IncreaseClientAsync {
171171
fun realTimePaymentsRequestForPayments(): RealTimePaymentsRequestForPaymentServiceAsync
172172

173173
fun simulations(): SimulationServiceAsync
174+
175+
/**
176+
* Closes this client, relinquishing any underlying resources.
177+
*
178+
* This is purposefully not inherited from [AutoCloseable] because the client is long-lived and
179+
* usually should not be synchronously closed via try-with-resources.
180+
*
181+
* It's also usually not necessary to call this method at all. the default HTTP client
182+
* automatically releases threads and connections if they remain idle, but if you are writing an
183+
* application that needs to aggressively release unused resources, then you may call this
184+
* method.
185+
*/
186+
fun close()
174187
}

increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsyncImpl.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,4 +467,6 @@ constructor(
467467
override fun webhooks(): WebhookServiceAsync = webhooks
468468

469469
override fun simulations(): SimulationServiceAsync = simulations
470+
471+
override fun close() = clientOptions.httpClient.close()
470472
}

increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientImpl.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,4 +451,6 @@ constructor(
451451
override fun webhooks(): WebhookService = webhooks
452452

453453
override fun simulations(): SimulationService = simulations
454+
455+
override fun close() = clientOptions.httpClient.close()
454456
}

0 commit comments

Comments
 (0)