JetBrains / kotless

Kotlin Serverless Framework
Apache License 2.0
1.15k stars 57 forks source link

Ktor features missing?! #81

Closed BlackHornet closed 2 years ago

BlackHornet commented 3 years ago

Hello,

first of all: Kotless is awesome 👍

As I'm using the ktor-lang for development I wonder if it is planned to support ktor Locations (afaik those are not added to the API Gateway in AWS).

In addition I wonder if it would be possible to add something like the Events API to the ktor-lang?! So it is possible to define additional periodic "tasks" in my project (e.g. download some kind of daily generated content to be cached in a S3 bucket, instead of fetching it everytime a lambda is called).

Regards

icehockeystar commented 3 years ago

you can use @Scheduled annotation https://site.kotless.io/pages/dsl/events

BlackHornet commented 3 years ago

As Scheduled is only part of kotless-lang I'm stuck :(

Only one dependency should be used for DSL: either "kotless-lang", "ktor-lang" or "spring-boot-lang".

icehockeystar commented 3 years ago

sorry man, I realized the problem later as well. What's the problem to add Scheduled event to the ktor-lang and spring-boot-lang ? My actual problem is that I want to have something like dependency injections in a project. This is not possible with kotless-lang, since everything is based on functions or objects there. I hoped that with ktor-lang I could use Koin or with spring-boot-lang the normal DI. But it seems that everything is based on objects and functions? Any ideas on it?

TanVD commented 3 years ago

Hey, yes as for the @Scheduled -- right now it is available in Kotless only and for Ktor I have to invent something based on functions. As for the dependency injection, you can use it in ktor-lang.. I don't know the reason why it should not be working... :)

BlackHornet commented 3 years ago

@icehockeystar koin is not a problem, just initialize it in prepare function of your Kotless class.

After that you can use by inject within any route to inject your desired class instances.