rocketraman
12/18/2018, 6:27 PMjava.util.concurrent.CancellationException: Channel has been cancelled
from the ktor client, using CIO, with the same code that used to work with 1.0.0. Anyone else experienced this?miha-x64
12/18/2018, 7:06 PMDias
12/19/2018, 10:38 AMwithContext
suspending calls to leverage coroutines better?Albert
12/19/2018, 2:38 PMMockEngine
Albert
12/19/2018, 2:50 PMMockEngine
like so MockEngine.invoke
. Otherwise it keeps referencing to the constructorobobo
12/19/2018, 2:58 PMval call = call {
url(URL(url))
method = HttpMethod.Get
}
Where is URL
defined? IntelliJ is having a hard time finding it.Alexander Potukar
12/19/2018, 3:32 PMahulyk
12/20/2018, 9:40 AMio.ktor.client.call.ReceivePipelineException: Fail to run receive pipeline
ext.kotlin_version = '1.3.10'
ext.coroutines_version = '1.0.1'
ext.ktor_version = '1.0.1'
ext.serialization_version = '0.9.1'
NGupta
12/20/2018, 1:08 PMrrader
12/21/2018, 8:18 AMgotoOla
12/21/2018, 12:12 PMimport our.company.toJsonString
import our.company.ApplicationMetrics
import io.ktor.client.HttpClient
import io.ktor.client.engine.apache.Apache
import io.ktor.client.engine.config
import <http://io.ktor.client.request.post|io.ktor.client.request.post>
import io.ktor.client.response.HttpResponse
import org.slf4j.LoggerFactory
class UpdateClient(
baseUrl: String
) {
private val logger = LoggerFactory.getLogger(UpdateClient::class.java)
private val client = HttpClient(Apache.config {
socketTimeout = 30_000
connectTimeout = 30_000
})
private val updateUrl = "$baseUrl/shared"
suspend fun postUpdates(updates: List<Update>) {
try {
val payload = updates.toJsonString()
<http://client.post|client.post><HttpResponse>(updateUrl) {
body = payload
}
ApplicationMetrics.updatesSent.labels("true").inc(updates.size.toDouble())
} catch (e: Exception) {
logger.error("Could not post updates", e)
ApplicationMetrics.updatesSent.labels("false").inc(updates.size.toDouble())
}
}
}
The service that calls this looks something like this
fun businessLogic(urls: List<Url>) {
runBlocking {
val urlsInDynamo = urls.map { url ->
GlobalScope.async {
try {
val result = dynamoClient.increaseSharesAsync(url)
Update(result.attributes()["aString"]?.s()!!, result.attributes()["aValue"]?.n()!!.toLong())
} catch (e: Exception) {
logger.warn("Unable to write get result from the update to dynamo", e)
null
}
}
}.awaitAll().filterNotNull()
if (urlsInDynamo.isEmpty()) {
throw RuntimeException("Non of the urls were updated in Dynamo")
}
// Fire and forget
GlobalScope.launch {
val updates = urlsInDynamo
.groupBy { it.aString }
.map {
it.value.maxBy {
it.value
}!!
}
.toList()
// This is where we call the update client at about 600 rps
updateClient.postUpdates(updates)
}
}
}
And the data class and extension we use
fun Any.toJsonString(pretty: Boolean = false): String {
return DefaultObjectMapper
.let { if (pretty) it.writer(SerializationFeature.INDENT_OUTPUT) else it.writer() }
.writeValueAsString(this)
}
data class Update(val aString: String, val aValue: Long)
Alexandre
12/23/2018, 6:37 PM./gradlew :teste:run
FAILURE: Build failed with an exception.
* What went wrong:
Project 'teste' not found in root project 'teste'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at <https://help.gradle.org>
BUILD FAILED in 0s
This is my gradle file:
buildscript {
ext.gretty_version = '2.0.0'
ext.kotlin_version = '1.3.11'
ext.ktor_version = '1.0.1'
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.akhikhl.gretty:gretty:$gretty_version"
}
}
plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.3.12'
id 'org.jetbrains.kotlin.jvm' version '1.3.0'
}
apply plugin: 'kotlin'
apply plugin: 'war'
apply plugin: 'org.akhikhl.gretty'
webAppDirName = 'webapp'
gretty {
contextPath = '/'
logbackConfigFile = 'resources/logback.xml'
}
sourceSets {
main.kotlin.srcDirs = [ 'src' ]
main.resources.srcDirs = [ 'resources' ]
}
repositories {
jcenter()
maven { url "<https://kotlin.bintray.com/ktor>" }
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "io.ktor:ktor-server-servlet:$ktor_version"
compile "io.ktor:ktor-html-builder:$ktor_version"
compile "ch.qos.logback:logback-classic:1.2.3"
}
kotlin.experimental.coroutines = 'enable'
task run
afterEvaluate {
run.dependsOn(tasks.findByName("appRun"))
}
where i'm worong?bod
12/23/2018, 7:52 PMsavrov
12/23/2018, 10:07 PMbod
12/24/2018, 12:00 AMkenkyee
12/24/2018, 12:25 PMbod
12/24/2018, 3:57 PMspierce7
12/24/2018, 9:11 PMspierce7
12/24/2018, 9:23 PMinstall(Authentication) {
in the context of Application
. How should I be doing this now?Jonas Bark
12/24/2018, 10:41 PMJonas Bark
12/24/2018, 11:11 PMCould not resolve all files for configuration ':common:iosCompileKlibraries'.
> Could not find io.ktor:ktor-http-iosx64:1.1.0.
It searches for this URL:
https://dl.bintray.com/kotlin/ktor/io/ktor/ktor-http-iosx64/1.1.0/ktor-http-iosx64-1.1.0.module which results in a 404 error, while the one with X64 instead of x64 does exist
https://dl.bintray.com/kotlin/ktor/io/ktor/ktor-http-iosX64/1.1.0/ktor-http-iosX64-1.1.0.modulebod
12/25/2018, 11:15 AMdefer
attribute to a script
tag.savrov
12/25/2018, 12:32 PMLucas
12/25/2018, 9:10 PMhandleWebSocketConversation
blocks the execution forever, so the test does not finish.bitkid
12/26/2018, 9:46 AMrusshwolf
12/26/2018, 11:57 PMio.ktor:ktor-client-core-ios:1.1.1
, io.ktor:ktor-client-json-ios:1.1.1
, or io.ktor:ktor-client-mock-ios:1.1.1
, but using iosx64
instead of ios
works fine. Oddly I have no issue with io.ktor:ktor-client-ios:1.1.1
.russhwolf
12/27/2018, 1:58 AMMETA-INF
files which were giving me build issues until I added this line: https://github.com/russhwolf/ktor-demo/blob/master/app/build.gradle#L27. I know I’ve seen other such issues in the past and they’ve been fixed. Is this a known issue currently?
2. Is the strategy I’m using to dynamically switch between x64 and arm64 dependencies sane? Also is it necessary, or did I miss something?hates
12/27/2018, 9:58 AMdotenv
gem to store environment variables in a .env
file then override them on the server with proper env variables, is there a good alternative for Kotlin/Ktor? Or a standard way of achieving the same thing?deviant
12/27/2018, 12:07 PMReduced JDK7/8 dependenciesdoes it mean you guys are moving in multiplatform direction?
Ameho Chan
12/27/2018, 12:12 PM