Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(client): add close method #87

Merged
merged 1 commit into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}