Out of curiosity, how do you guys trigger schedule...
# http4k
p
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
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
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
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
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
I'd probably go with pulumi for deploying lambdas nowadays. For our integration tests we deployed just using http4k itself
d
Yeah - the webinar we did with them used Graal https://github.com/http4k/server-as-a-function-webinar
p
Honestly I was so suprised how easy it and seamless was
d
That's how easy it's meant to be. You're just uncovering how messed up most other things are! 🤣
p
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
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
Sounds like a fun env to work in! Never tried Kotlin for CLI stuff
d
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
Honestly it’s just a function fetching data and sending it somewhere else. I guess I just have to finally try it out. 😄
d
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
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
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
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
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
Well we do support GCP functions as well... 😉
👍 1
p
Hehe, I’m aware of that. Will probably try that too with the GCP free tier, but no big hope in changing existing functins. 😛