Gunslingor
04/03/2020, 3:20 PM@Scheduled(fixedRate = 60000)
rocketraman
04/03/2020, 3:21 PMGunslingor
04/03/2020, 3:25 PMrocketraman
04/03/2020, 3:26 PM@Scheduled
annotation just abstracts over the JDKs executer API. See https://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ScheduledExecutorService.html.rocketraman
04/03/2020, 3:27 PMGunslingor
04/03/2020, 3:27 PMCasey Brooks
04/03/2020, 3:31 PMGunslingor
04/03/2020, 3:35 PMrocketraman
04/03/2020, 3:36 PMwhile
loop with a call to delay
... that idiom can extend to all sorts of use cases.Gunslingor
04/03/2020, 3:37 PMrocketraman
04/03/2020, 3:39 PMGunslingor
04/03/2020, 3:39 PMCasey Brooks
04/03/2020, 3:42 PMrocketraman
04/03/2020, 3:49 PMGunslingor
04/03/2020, 3:51 PMGunslingor
04/03/2020, 4:04 PMrocketraman
04/03/2020, 4:17 PMembeddedServer
. Personally I wouldn't mix the Aggregator
with the ktor app at all, as I don't see any need to -- I'd probably start
a separate coroutine or scheduled thread for that (via ScheduledExecutorService
which is newer and more robust than Timer
). Don't know what your web
and api
calls are doing so can't comment there.Gunslingor
04/03/2020, 4:18 PMrocketraman
04/03/2020, 4:19 PMGunslingor
04/03/2020, 4:20 PMrocketraman
04/03/2020, 4:21 PMmain
. Its not "ktor's main" when you use the embedded server, its just main
🙂Gunslingor
04/03/2020, 4:23 PMGunslingor
04/03/2020, 4:23 PMrocketraman
04/03/2020, 4:25 PMmodule
is just ktor's way of combining all your web-apps features and routing information. Its providing you a nice DSL as Application
is its receiver.rocketraman
04/03/2020, 4:25 PMApplication
at all, so there is no need to couple them together.Gunslingor
04/03/2020, 4:27 PMrocketraman
04/03/2020, 4:28 PMGunslingor
04/03/2020, 4:42 PMrocketraman
04/03/2020, 4:45 PMApplication.module
adds a module to a list of modules. Also note the top-level docs https://ktor.io/servers/index.html indicate:
Application modules are started one by one when an application is started, and every module can configure an instance of the application. An application instance is configured by installing features and intercepting pipelines.
rocketraman
04/03/2020, 4:46 PMGunslingor
04/03/2020, 4:46 PMGunslingor
04/03/2020, 4:47 PMGunslingor
04/03/2020, 4:48 PMrocketraman
04/03/2020, 4:48 PMrocketraman
04/03/2020, 4:49 PMGunslingor
04/03/2020, 4:49 PMrocketraman
04/03/2020, 4:51 PMGunslingor
04/03/2020, 4:53 PMrocketraman
04/03/2020, 5:00 PMGunslingor
04/03/2020, 5:01 PMGunslingor
04/03/2020, 7:24 PMfun Application.api() { }
currently I have routing and a function for json output in there... but should routing be segregated for a large project and, if so, what would that look like (e.g. Application.api.routes or many can it be turned into a class with member routes?)? Also if it is separated, what else is there... obviously there would have to be more than routes.