Skip to content
Permalink
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (33 sloc) 905 Bytes
package droidkaigi.github.io.challenge2019.ingest
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import kotlin.random.Random
class IngestManager {
/**
* 計測を行うメソッドです
* 通信のステータスコードを返します
*/
fun track(): Int {
val latch = CountDownLatch(1)
//なんかすごく重い通信処理
Thread.sleep(10000)
//statusCodeの代わりです
val response = Random.nextInt(0, 10)
return when (response) {
1 -> {
latch.countDown()
latch.await()
500
}
2 -> {
latch.await(5, TimeUnit.SECONDS)
503
}
else -> {
latch.countDown()
latch.await()
200
}
}
}
}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.