This message was deleted.
# http4k
s
This message was deleted.
p
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
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
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
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
Here’s the whole log for one triggered request:
Using
ApiGatewayV1LambdaFunction
d
That's a timeout. Try it again?
p
OOM is checked. Max ~150mb used, 512mb configured
d
Need to see the 500 coming back in the logs 🙃
Try upping the timeout or the memory (this increases performance)
p
I’m an idiot
d
We're all idiots occasionally 🤣
p
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
So does it work then? 🙃
✔️ 1
p
It does! The JSON is so big that it obviously takes a little bit longer than 7secs. 😄
d
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
Well, Graal is step 2! That’s probably the main argument to later on convince my colleagues. 🌚