Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Allow custom executor/thread pool for async HTTP calls in CompletionServiceAsyncImpl

Abierto
#754 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
65/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
kotlin
Área
api, backend

Línea de trabajo

Comienza con el uso del executor referenciado en openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsyncImpl.kt y, después, sigue OpenAIClient.builder() para encontrar dónde se ensambla la configuración del cliente. Determina cómo debe llegar el executor configurado al servicio asíncrono y verifica que las llamadas HTTP asíncronas lo utilicen en lugar de ForkJoinPool.commonPool().

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Description

CompletionServiceAsyncImpl currently uses the JVM ForkJoinPool.commonPool() to invoke async HTTP calls:

https://github.com/openai/openai-java/blob/main/openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsyncImpl.kt#L143

In enterprise environments, relying on the global common pool can break tracing, observability, and context propagation flows. Many applications use custom executors/thread pools to preserve tracing context, MDC/logging context, OpenTelemetry context, or other request-scoped metadata across async boundaries.

Because the common pool is not customizable, users cannot currently integrate the OpenAI Java client cleanly with their existing execution and observability infrastructure.

Problem

There is currently no supported way to override the thread pool used by CompletionServiceAsyncImpl.

The only workaround is to copy the generated/service implementation class and modify the executor usage manually, which is fragile and difficult to maintain across library upgrades.

Proposed Solution

Provide an option to configure the executor/thread pool when building the client.

For example:

val client = OpenAIClient.builder()
.apiKey(apiKey)
.executor(customExecutor)
.build()

or, if scoped specifically to async execution:

val client = OpenAIClient.builder()
.apiKey(apiKey)
.asyncExecutor(customExecutor)
.build()

The async service implementation could then use the configured executor instead of ForkJoinPool.commonPool().

Expected Behavior

Users should be able to supply a custom executor so async HTTP calls run on infrastructure-controlled threads, allowing tracing, observability, and context propagation to work correctly.

Current Workaround

The current workaround is to copy CompletionServiceAsyncImpl and modify the implementation to use a custom executor, but this is not ideal because it forks library internals and creates maintenance risk.

Additional Context

This is especially important in enterprise scenarios where applications require strict control over execution context, thread naming, tracing propagation, and monitoring behavior.

Lenguaje dominante
Kotlin
Estrellas
1.5k
Forks
264
Merge medio
13 h 31 min
PR fusionados (30 d)
89

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de openai/openai-java

Todos los issues de openai/openai-java

Issues similares

Más issues de Kotlin

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.