use old memes
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2020-10-22 20:46:58 +02:00
parent 215bb0ed13
commit c0066bb414
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
2 changed files with 12 additions and 11 deletions

View File

@ -30,7 +30,8 @@ fun Application.module(testing: Boolean = false) {
startTime = Instant.now() startTime = Instant.now()
while (elapsed < targetTime) { while (elapsed < targetTime) {
currIter += 1 currIter += 1
currUploader = Uploader(currIter) currUploader = Uploader()
currUploader.currIteration = currIter
currUploader.buildRequest() currUploader.buildRequest()
uploaders.add(currUploader) uploaders.add(currUploader)
currTimeStamp = Instant.now() currTimeStamp = Instant.now()

View File

@ -1,19 +1,17 @@
package com.kmlabz.k8s package com.kmlabz.k8s
import com.google.gson.Gson
import com.google.gson.GsonBuilder import com.google.gson.GsonBuilder
import io.ktor.client.* import io.ktor.client.*
import io.ktor.client.engine.apache.* import io.ktor.client.engine.apache.*
import io.ktor.client.request.* import io.ktor.client.request.*
import io.ktor.client.request.forms.* import io.ktor.client.request.forms.*
import io.ktor.client.statement.*
import io.ktor.http.* import io.ktor.http.*
import io.ktor.http.content.* import io.ktor.http.content.*
import io.ktor.util.* import io.ktor.util.*
import java.io.File import java.io.File
import java.time.Instant import java.time.Instant
class Uploader(currIteration: Int) { class Uploader{
private val gson = GsonBuilder().setPrettyPrinting().create() private val gson = GsonBuilder().setPrettyPrinting().create()
private val inputSound = File("/app/wave.wav").readBytes() private val inputSound = File("/app/wave.wav").readBytes()
private lateinit var parts: List<PartData> private lateinit var parts: List<PartData>
@ -42,9 +40,11 @@ class Uploader(currIteration: Int) {
@KtorExperimentalAPI @KtorExperimentalAPI
suspend fun sendRequest() { suspend fun sendRequest() {
HttpClient(Apache).post<HttpResponse>(System.getenv("URL") ?: "https://birb.k8s.kmlabz.com/benchmark") { HttpClient(Apache).use { client ->
body = parts client.submitFormWithBinaryData<Unit>(formData = parts) {
url(System.getenv("URL") ?: "https://birb.k8s.kmlabz.com/benchmark")
} }
respInstant = Instant.now() respInstant = Instant.now()
} }
} }
}