testcontainers / testcontainers/testcontainers-java
Use Executor in AbstractWaitStrategy
Personne n'a encore pris cette issue.
- Langage dominant
- Java
- Étoiles
- 8.7k
- Forks
- 1.9k
- Merge moyen
- 2 j 17 h
- PR mergées (30 j)
- 9
Description
I am trying to bridge to a suspend version of waitUntilReady in AbstractWaitStrategy with something along the lines of:
suspend fun strategy(waitingStrategyTarget: WaitingStrategyTarget): Unit {
// run your strategy
}
class MyWaitStrategy : AbstractWaitStrategy() {
override fun waitUntilReady() {
val executor: ExecutorService = EXECUTOR // executor from AbstractWaitStrategy
runBlocking(executor.asCoroutineDispatcher()) {
strategy(waitingStrategyTarget)
}
}
}
or in a TestScope with JUnit this may look like:
@Test
fun testWithSuspendedWaitStrategy() =
runTest {
val strategy =
waitStrategy { target ->
// run my strategy
}
// MyContainer.waitUntil(strategy, ....)
}
fun TestScope.waitStrategy(
f: CoroutineScope.(target: WaitStrategyTarget) -> Unit
): AbstractWaitStrategy =
object : AbstractWaitStrategy() {
override fun waitUntilReady() {
launch(EXECUTOR.asCoroutineDispatcher()) {
f(this, waitStrategyTarget)
}
}
}
Is there a way how to implement this with EXECUTOR, being public instead of package private, or with another Executor, ExecutorService or something.
Any Feedback is welcome :D
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par lire core/src/main/java/org/testcontainers/containers/wait/strategy/AbstractWaitStrategy.java, en particulier la déclaration de EXECUTOR et l’intégration de waitUntilReady. L’issue fournit des exemples de coroutines Kotlin, mais aucun test nommé ni critère d’acceptation ; une modification terminée nécessiterait une approche concertée pour exposer ou remplacer l’exécuteur, ainsi qu’une méthode définie pour vérifier les stratégies d’attente suspendues.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- java, kotlin
- Domaine
- testing
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 20/100