https://kotlinlang.org logo
#http4k
Title
# http4k
s

Slackbot

06/01/2022, 9:48 PM
This message was deleted.
p

Philipp Mayer

06/01/2022, 9:49 PM
Here are the DTOs:
Copy code
private data class RawFlashScoreResponse(
    val DATA: List<League>,
) : List<RawFlashScoreResponse.League> by DATA {
    data class League(
        val NAME: String,
        val EVENTS: List<Event>,
    ) {
        data class Event(
            val FH: String,
            val FK: String,
            val START_TIME: Long,
        )
    }
}

private fun RawFlashScoreResponse.toSchedules() = Schedules(map { Schedule(it.NAME, it.EVENTS.toGames()) })

private fun List<RawFlashScoreResponse.League.Event>.toGames() = map {
    Game(Instant.ofEpochSecond(it.START_TIME), it.FH, <http://it.FK|it.FK>)
}
d

dave

06/02/2022, 6:25 AM
What does the outside layer (invoker) look like? Ideas: • If you are getting a 500 then have you tried a simple try catch block? • better idea - if it's an http lambda put a CatchAll filter around the inbound. And also a debugging filter on the inbound I'm assuming it's a lens failure - the stack should tell you what went wrong with Moshi
p

Philipp Mayer

06/02/2022, 7:11 AM
I just published my super hacky code here. Right now, I’m still triggering it via http here. I set up CatchAll and CatchLensFailure here. Thank you for your ideas! I tried a simple
runCatching {}.onFailure { printSomething}
around the lens, no luck. The thing I’m suprised about is that it works locally. ( It works on my machine!!!!111 )
Here are my logs (debug is set here):
Sorry for the spam, but it grinds my gears
d

dave

06/02/2022, 7:15 AM
What do the logs show? Are you using v1 or V2 of the lambda protocol? Are you sure that the code doesn't get to the second line? (Just checking!)
Reason I ask is that it could be blowing up after its served the request in the aws adapter layer
Other thing: same behaviour if you invoke the lambda from the Aws console? Is it running OOM?
p

Philipp Mayer

06/02/2022, 7:22 AM
Here’s the whole log for one triggered request:
Using
ApiGatewayV1LambdaFunction
d

dave

06/02/2022, 7:24 AM
That's a timeout. Try it again?
p

Philipp Mayer

06/02/2022, 7:24 AM
OOM is checked. Max ~150mb used, 512mb configured
d

dave

06/02/2022, 7:25 AM
Need to see the 500 coming back in the logs 🙃
Try upping the timeout or the memory (this increases performance)
p

Philipp Mayer

06/02/2022, 7:26 AM
I’m an idiot
d

dave

06/02/2022, 7:27 AM
We're all idiots occasionally 🤣
p

Philipp Mayer

06/02/2022, 7:27 AM
Double-checking helps a lot, heh. I thought I set the timeout to 70sec. Turns out it was 7..
Thanks a lot for your help! Will now continue moving it to the Cron Event. Again, thanks for the great docs and examples everywhere. 👍
d

dave

06/02/2022, 7:28 AM
So does it work then? 🙃
✔️ 1
p

Philipp Mayer

06/02/2022, 7:28 AM
It does! The JSON is so big that it obviously takes a little bit longer than 7secs. 😄
d

dave

06/02/2022, 7:31 AM
Yeah, this is why we generally try to go with the generated adapters for Moshi and the Graal runtime. Obvs not for a pet project, but makes a massive difference
But - glad you've got it sorted!
p

Philipp Mayer

06/02/2022, 7:40 AM
Well, Graal is step 2! That’s probably the main argument to later on convince my colleagues. 🌚
3 Views