Skip to content

Commit

Permalink
feat(client): add close method (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jan 29, 2025
1 parent 7ca4de4 commit 063e1c1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,17 @@ interface AnthropicClient {
fun models(): ModelService

fun beta(): BetaService

/**
* Closes this client, relinquishing any underlying resources.
*
* This is purposefully not inherited from [AutoCloseable] because the client is long-lived and
* usually should not be synchronously closed via try-with-resources.
*
* It's also usually not necessary to call this method at all. the default HTTP client
* automatically releases threads and connections if they remain idle, but if you are writing an
* application that needs to aggressively release unused resources, then you may call this
* method.
*/
fun close()
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,17 @@ interface AnthropicClientAsync {
fun models(): ModelServiceAsync

fun beta(): BetaServiceAsync

/**
* Closes this client, relinquishing any underlying resources.
*
* This is purposefully not inherited from [AutoCloseable] because the client is long-lived and
* usually should not be synchronously closed via try-with-resources.
*
* It's also usually not necessary to call this method at all. the default HTTP client
* automatically releases threads and connections if they remain idle, but if you are writing an
* application that needs to aggressively release unused resources, then you may call this
* method.
*/
fun close()
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ constructor(
override fun models(): ModelServiceAsync = models

override fun beta(): BetaServiceAsync = beta

override fun close() = clientOptions.httpClient.close()
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ constructor(
override fun models(): ModelService = models

override fun beta(): BetaService = beta

override fun close() = clientOptions.httpClient.close()
}

0 comments on commit 063e1c1

Please sign in to comment.