Add scheduling
This commit is contained in:
parent
16a0740679
commit
1c59227030
2 changed files with 11 additions and 3 deletions
|
@ -1,13 +1,15 @@
|
|||
package de.rpr.githubreleases
|
||||
|
||||
import okhttp3.OkHttpClient
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
fun main() {
|
||||
val config = Config()
|
||||
val publishers = Publishers(config)
|
||||
val releaseRepository = ReleaseRepository()
|
||||
val app = App(config, releaseRepository, OkHttpClient(), publishers)
|
||||
app.execute()
|
||||
app.schedule()
|
||||
}
|
||||
|
||||
class App(
|
||||
|
@ -17,7 +19,13 @@ class App(
|
|||
private val publishers: Publishers
|
||||
) {
|
||||
|
||||
fun execute() {
|
||||
fun schedule() {
|
||||
log("Scheduling app...")
|
||||
val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
executor.scheduleAtFixedRate({ execute() }, 5, config.schedulingDelay, TimeUnit.SECONDS)
|
||||
}
|
||||
|
||||
private fun execute() {
|
||||
|
||||
config.githubRepos.forEach { githubRepo ->
|
||||
val existingReleases = releaseRepo.getExistingReleases(githubRepo)
|
||||
|
|
|
@ -17,7 +17,7 @@ class Config {
|
|||
validate()
|
||||
}
|
||||
|
||||
fun validate() {
|
||||
private fun validate() {
|
||||
if (instanceUrl.isNullOrBlank()) {
|
||||
ERROR.log("No instance url available, please set the environment variable $instanceUrlEnvName")
|
||||
valid = false
|
||||
|
|
Loading…
Reference in a new issue