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

Philipp Mayer

05/15/2022, 5:05 PM
Out of curiosity, how do you guys trigger scheduled lambda functions? I’m trying playing around with AWS + serverless for the first time in a private project and wanted to trigger a lambda e.g. once a day. I saw in an [aws example repo](https://github.com/cdk-patterns/serverless/blob/main/the-scheduled-lambda/java/src/main/java/com/cdkpatterns/TheScheduledLambdaApp.java) that one can pull in the amazon CDK to have a builder inside the app itself, but I guess this would not work with http4k’s own implementation. So, how do you guys usually do this? I guess I can also trigger it from the outside, but wanted to check first. (Sorry for being partly off-topic here!)
s

s4nchez

05/15/2022, 5:06 PM
You can still use http4k for those if you configure it to listen to the expected event https://www.http4k.org/guide/reference/serverless/#aws_lambda_integration_event-based_apps
p

Philipp Mayer

05/15/2022, 5:11 PM
Ah, now I see. I just saw some support for
ScheduledEvent
in the change log and wasn’t sure how that could help me. I’ll look into it, thanks a lot! Btw I gotta say the experience is really outstanding right now, thanks for that delight of a library. 👍
j

James Richardson

05/15/2022, 5:37 PM
Btw the example in the amazon cdk thing there is about setting up an eventbridge link to invoke a (nodejs) lambda... not to do with what happens when the lambda gets invoked.
There are loads of ways the lambda code itself can be deployed.. e.g. clicky clicky, SAM, terraform, ..
p

Philipp Mayer

05/15/2022, 5:43 PM
Oh damn, you’re so right James. I’m actually with Pulumi right now. Next step is to try out Graal. I actually have some reading to do about when to go for graal and when for the JVM, I think @dave mentioned something about it in the jetbrains webinar that got me thinking.
s

s4nchez

05/15/2022, 5:44 PM
I'd probably go with pulumi for deploying lambdas nowadays. For our integration tests we deployed just using http4k itself
d

dave

05/15/2022, 5:45 PM
Yeah - the webinar we did with them used Graal https://github.com/http4k/server-as-a-function-webinar
p

Philipp Mayer

05/15/2022, 5:45 PM
Honestly I was so suprised how easy it and seamless was
d

dave

05/15/2022, 5:46 PM
That's how easy it's meant to be. You're just uncovering how messed up most other things are! 🤣
p

Philipp Mayer

05/15/2022, 5:46 PM
Yeah I think you mentioned something about that it might be worth to go for the JVM instead of native in high traffic scenarios, but I gotta check that first if I remember correctly.
Oh you’re so right..
d

dave

05/15/2022, 5:47 PM
We're using pulumi in anger on a side project a it's really clean so far
If you use http4k-connect as well and Moshi with generated adapters then you can get really lightweight (and super fast) native lambdas. We're also using Graal to create CLI binaries for Linux, Mac and windows
p

Philipp Mayer

05/15/2022, 5:49 PM
Sounds like a fun env to work in! Never tried Kotlin for CLI stuff
d

dave

05/15/2022, 5:50 PM
We ended up going with clikt, which is fairly testable (but definitely hasn't been TDDd 🤣)
😂 1
Anything you can do to strip out reflection is the name of the game
p

Philipp Mayer

05/15/2022, 5:52 PM
Honestly it’s just a function fetching data and sending it somewhere else. I guess I just have to finally try it out. 😄
d

dave

05/15/2022, 5:53 PM
Well of course the standard aws functions use Jackson so native is more hassle. But spin up time for a scheduled lambda is probably not worth optimising! 🤣
💯 2
p

Philipp Mayer

05/15/2022, 5:54 PM
It’s mainly about playing around with it and later on showing it to colleagues, so just showing that it’s possible might be quite interesting for them. 🌚
Doing my best to not having JS only anymore for serverless
d

dave

05/15/2022, 5:56 PM
Actually - it's been shown that the size of the lambda package has a lot to do with it. And node lambdas do have a hell of a lot of dependencies...
j

James Richardson

05/15/2022, 5:57 PM
You might find that spin up time for http4k lambda is acceptable out-of-the-box. After that you may find that proguard could work for you - this is easy when there is no reflection, or graal, depending on which you find easier.
p

Philipp Mayer

05/15/2022, 6:00 PM
Thanks for the pointer, I will for sure have a look! We’re currently finishing up a big project on GCP, so nothing will change there, but I want to be prepared to showcase http4k-lambdas once we’re on AWS, which is planned for later this year.
d

dave

05/15/2022, 6:18 PM
Well we do support GCP functions as well... 😉
👍 1
p

Philipp Mayer

05/15/2022, 6:23 PM
Hehe, I’m aware of that. Will probably try that too with the GCP free tier, but no big hope in changing existing functins. 😛