https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
server
  • j

    Juan-Carlos Foust

    01/05/2021, 6:38 AM
    Hi folks. Apologies — I am not a Kotlin expert. I currently work at a co that has several Kotlin web services built on Dropwizard, JOOQ, Sqitch. They’ve served our org well and I’m planning on taking a similar direction for a new web service that needs to be built. I was wondering if anyone in this group has strong opinions on technology selections I might consider in the new service that could benefit our org overall in the long term (considering where we are at currently). I’m very unfamiliar with the landscape of options out there. I’m especially interested in any experience folks have with developing gRPC services or other approaches to automating server-endpoint and api-client construction in a Kotlin context.
    d
    d
    +4
    • 7
    • 12
  • f

    forrest

    01/05/2021, 3:59 PM
    Question about testing ktor. Has anyone had luck mocking an ApplicationRequest? I'd like to be able to write unit tests without the whole test server harness, which has been fine for integration testing but a bit much for unit tests. Specifically, I just want to test a function that parses a request, so I just want to pass my function a test request without having to make a call to the test server to get one
    t
    d
    • 3
    • 15
  • b

    Byron Katz

    01/06/2021, 12:28 AM
    Hi folks, I've been building a simplicity-prioritized web application from the ground-up, with the fewest possible dependencies. That means I also built a server for this, using Socket and ServerSocket. It's been of the ordinary blocking kind, and I'm pretty happy. But not complacent. Right now I'm doing some research to see if there's any low-hanging fruit in terms of massive speed gains. The driving business paradigm is that the application is for timekeeping at a company. If I run the code to add a time entry below the server layer, I can add a million time entries per second (thread-safely! It's atomic indexes and ConcurrentHashMap for the shared mutable state). However, if I do the equivalent through the server layer, it's down to eleven thousand per second. Yuck. Well, I mean it's ok and all, but I want a million if there's some easy way to have it. One of the big bottlenecks is the back-and-forth of the HTTP protocol, where the server examines the first line to see what it is (GET? POST? etc) and then reads the headers (Does it have a content-length?, Who is this, per the cookie?) and then assembles a response in kind. It also complicates things that I am handling keep-alive as well. That means the client might decide to stay on the socket for the next back-and-forth. Which leads me to the idea of non-blocking. If I do that, sure, each individual request/response should be the same performance, but with all that waiting taking place in blocking servers, I would imagine I could parallelize this tremendously and get my million requests per second. Questions: 1. Am I insane? 2. Is non-blocking the answer to this? 3. I've looked at Ktor's code. Is there other code that covers similar ground, written in pure Kotlin, test/quality-oriented, that's fast?
    d
    a
    j
    • 4
    • 12
  • f

    Filip Lastic

    01/09/2021, 6:54 AM
    [Ktor] Hello! Please, it is possible to read resources/application.conf file in build.gradle? I have database connection stored in application.conf, and need to run scripts which use database connection.
    c
    • 2
    • 2
  • j

    Jeff

    01/18/2021, 8:11 AM
    Hello everyone. Any ideas on how to implement microservices with ktor? I am specifically looking for information on the general architecture and how the services communicate with each other. Looking to have the following implemented: • API gateway • Logging • Dashboard e.t.c
    m
    • 2
    • 2
  • t

    Tauhid Rehman

    01/19/2021, 9:12 AM
    hey everyone, need a bit quick help. pseudocode: When there is a “specialCase” error, throw the exception and Log this exception as “Info”. This is the if statement I have. Does this look like a good approach?
    if (error.contains (specialCase)) {
        throw specialCaseException
    }
        <http://LOGGER.info|LOGGER.info>("logspecialCaseInfoAsInfo")
    :kotlin-intensifies: 3
    t
    m
    • 3
    • 6
  • j

    Júlio Santos

    01/20/2021, 12:43 PM
    Hello everybody! Has anyone here ever worked with
    Server-Sent Events
    ? I'm struggling to find clear examples
    a
    • 2
    • 4
  • j

    Joaquim Costa

    01/20/2021, 9:50 PM
    Hello everyone, Kotlin JPA Entity constructor issue in Java. I working on a spring/java server application. I started refactoring some entities to use Kotlin, but I am having some challenges invoking default constructor from Java class. This is a maven project using kotlin-maven-plugin with jpa, and spring. For some reason i am able to invoke the no arg constructor in java class as new Person(), and when this happens the default values of that object are all set to null, instead of preserving the value that i defined in the Person class. i expect the new Person() to yield a syntax error similar to when it is invoked in Kotlin class, or at least if the default constructor is used/allowed to be invoked from java it should use the default values in the fields. What am i missing?
    >The no-arg compiler plugin generates an additional zero-argument constructor for classes with a specific annotation.
    The generated constructor is synthetic so it can’t be directly called from Java or Kotlin, but it can be called using reflection.
    https://kotlinlang.org/docs/reference/compiler-plugins.html#no-arg-compiler-plugin
    example Person.kt
    @Entity class Person(
      @Id var id:Long?=0,
      var type:String="A"
    ){
      var description:String="none"
    }
    ❤️ 1
    n
    • 2
    • 3
  • c

    Cheenu Soni

    01/21/2021, 1:35 AM
    I am creating REST APIs. Where do the APIs pick the values from( in the server side)? What exactly happens at the server side? I want to pass some values daily to the users.
    ❓ 3
    c
    a
    • 3
    • 6
  • c

    Cheenu Soni

    01/22/2021, 3:00 AM
    2021-01-22 07:53:46.910 [main] INFO  Application - No ktor.deployment.watch patterns specified, automatic reload is not active
    2021-01-22 07:53:47.642 [main] INFO  Application - Responding at <http://0.0.0.0:8080>
    I only got this output
    a
    a
    • 3
    • 2
  • z

    Zeeshan Syed

    01/22/2021, 4:27 AM
    Hey @Cheenu Soni Please just create one thread. It will be easy for others to reply.. Have you tried localhost:8080? And also, you have to put a routing for "/" and respond something..
    c
    j
    v
    • 4
    • 14
  • s

    Slackbot

    01/23/2021, 11:05 PM
    This message was deleted.
    a
    m
    • 3
    • 3
  • m

    Mark

    01/25/2021, 1:39 AM
    Hello! This is a very newbie question but just starting to learn now. When doing a login with social (my example GitHub), I receive an access token from the service then I register the user on my database with username and email, but what do I do with the token? Should I store the token on the database then send it to the client to store there too so they can login? Should I generate my own token and store then send to the client? Or would it be something else? Just trying to understand a bit this concept, seems so complex for me. Thank you!
    a
    a
    • 3
    • 8
  • a

    Akshay Shah

    01/27/2021, 5:50 PM
    Does anyone have idea about writing a cron job/ schedule job in Ktor..I want to do some clean up after every 24 hours or hit a remote API and fetch some data and store it in database ?
    d
    p
    +3
    • 6
    • 8
  • p

    PengChunxiao

    01/28/2021, 9:24 AM
    How to use GRPC?
    :google: 5
    :kotlin-flag: 1
    m
    a
    • 3
    • 2
  • d

    dave

    01/29/2021, 3:26 PM
    Following Josh Graham's awesome post about Hotwire on the JVM, I got curious and had a go at supporting it in http4k. Turns out it was really easy so I built an example... 🙂 https://github.com/http4k/examples/tree/master/hotwire
    👍 1
    k
    • 2
    • 1
  • l

    Lucas Milotich

    02/01/2021, 11:39 AM
    Hello. Have anyone implemented a rest api or microservice using ktor, any dependency injection framework as koin, ddd and clean architecture?
    b
    j
    +4
    • 7
    • 11
  • j

    Júlio Santos

    02/04/2021, 5:26 PM
    Speak personal! Has anyone here had any experience working with high csv file processing with Kotlin? Could you explain how? Thanks
    :google: 2
    e
    p
    • 3
    • 5
  • j

    Jeff

    02/08/2021, 6:17 AM
    Can someone explain the 'new JVM backend' introduced in Kotlin 1.4.30
    e
    m
    • 3
    • 2
  • t

    Tamer Shahin

    02/08/2021, 9:45 AM
    what's the best way to define it in kotlin?
    e
    • 2
    • 1
  • r

    rocketraman

    02/08/2021, 6:57 PM
    What are people using these days for a multi-process task distribution system, that is tightly integrated with Kotlin and coroutines? I've used Kafka, Akka, ActiveMQ, and Pulsar in the past, but am looking for something a little lighter weight, focused on task distribution, and more Kotlinish. Right now, I'd lean towards Vert.X or Akka, or maybe even building something custom with rsocket.io.
    a
    • 2
    • 2
  • a

    Aaron Chancey

    02/09/2021, 4:51 PM
    Is there a way to access the call data from ktor to get the principal in my service layer or do I have to pass it down the chain?
    a
    • 2
    • 1
  • m

    Mark

    02/09/2021, 8:30 PM
    I am trying to learn Backend/Frontend development and one of my challenges so far has been to understand JWT authentication. But the more I research this topic the more confused I get. I have seen that storing the JWT token on the frontend's localstorage is a bad thing and I should be doing it via HttpOnly cookies. However for me to use the token on frontend I would need to access it from the cookie, which I can't because it's HttpOnly, so I figured I would just make calls to the backend while having the cookie and the backend would send the data back already authorized, however I was then told that the token should be passed in the authentication header and not in the cookie. So I wanted to ask, what is the correct way to handle this situation? Do I query the backend with the cookie, get the token back, store the token in memory then quary the backend again for data using the token in the authentication header? This sounds a bit counter productive, no? I really want to learn this topic and learn what is the correct way to secure the login.
    j
    a
    e
    • 4
    • 4
  • t

    Tarun Chawla

    02/12/2021, 8:30 AM
    I updated the driver from 0.8.4 to 0.8.6 and am no longer seeing the warning. Please let me know if there is a potential issue with my code which I need to debug.
    a
    o
    • 3
    • 4
  • d

    Denis Ambatenne

    02/12/2021, 9:53 AM
    Hi all, in case you have missed it! 👋 In Kotlin 1.4.30 :kotlin:, we've announced the Beta stage of the new JVM IR backed. This article describes what it is and why it's important to enable it. But let me repeat the article's central thesis here: please, switch on the JVM IR backend and build your project. And if you will face any problems, please use the YouTrack link or this Slack channel to submit your concern or ask a question.  This version of the JVM backend compiler becomes a default one since 1.5. So, we need to test it very-very well, and for that, we call the Community for this kind of activity. And we hope you will answer our call. With love, Kotlin Team.
    👍 5
    c
    • 2
    • 1
  • y

    YASAN

    02/13/2021, 6:15 AM
    My problem is that whenever I open the project lots of code is red and I get "Error: Could not find or load main class dev.yasan.wallpapers.ApplicationKt Caused by: java.lang.ClassNotFoundException: dev.yasan.wallpapers.ApplicationKt" Error. I have not found a proper fix yet. I just have to rebuild the project like 10+ times and it gets fixed randomly. How do I fix this? its really annoying
    e
    d
    d
    • 4
    • 17
  • j

    Jason5lee

    02/15/2021, 2:10 AM
    Is there any document or tutorial about creating a jlink image of a ktor service?
    a
    • 2
    • 1
  • r

    Rob Elliot

    02/19/2021, 11:18 AM
    Hey - I’ve got an immutable JPA Entity. It’s got a big String field on it which happens to contain JSON, and I’ve got a method that uses jackson to turn it into a Map. I’d like to memoize the result of that, as it’s never going to change, but lazily so I don’t incur the cost until I need it. But this doesn’t work:
    @Entity data class MyImmutableEntity(val jsonString: String) {
    
      @javax.persistence.Transient private val jsonMap: Map<String, Any> by lazy {
        jacksonObjectMapper().readValue(jsonString)
      }
    
      fun getJsonMap(): Map<String, Any> = jsonMap
    }
    The compiler complains about
    @Transient
    -
    This annotation is not applicable to target 'member property with delegate'
    . Anyone know of a workaround for this?
    r
    c
    • 3
    • 12
  • j

    jean pokou

    02/23/2021, 1:01 PM
    Hi, I am playing with ktor and I trying to deploy to google appengine using a uberJar. How can I pass my environment variable ( DATABASE_URL, …. ).
    p
    a
    • 3
    • 5
  • d

    dave

    02/24/2021, 1:54 PM
    For people that are interested in this type of thing, the TechEmpower benchmark round 20 is out: https://www.techempower.com/benchmarks/#section=data-r20&amp;hw=cl&amp;test=composite&amp;l=xan3h7-sf&amp;f=0-0-0-0-0-0-0-0-8-4fti4g-0-0
    r
    a
    e
    • 4
    • 7
Powered by Linen
Title
d

dave

02/24/2021, 1:54 PM
For people that are interested in this type of thing, the TechEmpower benchmark round 20 is out: https://www.techempower.com/benchmarks/#section=data-r20&amp;hw=cl&amp;test=composite&amp;l=xan3h7-sf&amp;f=0-0-0-0-0-0-0-0-8-4fti4g-0-0
r

Robert Jaros

02/24/2021, 2:33 PM
It's terrible to see that all Kotlin/Java JVM frameworks are much worse than some simple JavaScript framework "just-js" 😉
a

asad.awadia

02/24/2021, 3:17 PM
Tech empower is not credible or trust worthy. I would nof base anything on their results
👍 1
d

dave

02/24/2021, 3:19 PM
"webscale!" 😂 .
Interesting question - what IS credible?
☝️ 1
➕ 1
e

edrd

02/24/2021, 5:03 PM
Seems like
just
is an alternative JS runtime, in development stage
Probably should not be considered
d

dave

02/24/2021, 5:29 PM
@edrd since when did that stop anyone from slamming things straight into prod? 😂
😂 3
View count: 3