File tree Expand file tree Collapse file tree 4 files changed +30
-0
lines changed
openai-java-core/src/main/kotlin/com/openai/client Expand file tree Collapse file tree 4 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -39,4 +39,17 @@ interface OpenAIClient {
3939 fun batches (): BatchService
4040
4141 fun uploads (): UploadService
42+
43+ /* *
44+ * Closes this client, relinquishing any underlying resources.
45+ *
46+ * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and
47+ * usually should not be synchronously closed via try-with-resources.
48+ *
49+ * It's also usually not necessary to call this method at all. the default HTTP client
50+ * automatically releases threads and connections if they remain idle, but if you are writing an
51+ * application that needs to aggressively release unused resources, then you may call this
52+ * method.
53+ */
54+ fun close ()
4255}
Original file line number Diff line number Diff line change @@ -39,4 +39,17 @@ interface OpenAIClientAsync {
3939 fun batches (): BatchServiceAsync
4040
4141 fun uploads (): UploadServiceAsync
42+
43+ /* *
44+ * Closes this client, relinquishing any underlying resources.
45+ *
46+ * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and
47+ * usually should not be synchronously closed via try-with-resources.
48+ *
49+ * It's also usually not necessary to call this method at all. the default HTTP client
50+ * automatically releases threads and connections if they remain idle, but if you are writing an
51+ * application that needs to aggressively release unused resources, then you may call this
52+ * method.
53+ */
54+ fun close ()
4255}
Original file line number Diff line number Diff line change @@ -104,4 +104,6 @@ constructor(
104104 override fun batches (): BatchServiceAsync = batches
105105
106106 override fun uploads (): UploadServiceAsync = uploads
107+
108+ override fun close () = clientOptions.httpClient.close()
107109}
Original file line number Diff line number Diff line change @@ -96,4 +96,6 @@ constructor(
9696 override fun batches (): BatchService = batches
9797
9898 override fun uploads (): UploadService = uploads
99+
100+ override fun close () = clientOptions.httpClient.close()
99101}
You can’t perform that action at this time.
0 commit comments