https://github.com/funyin/kronos
A kotlin multiplatform libary for scheduling persistent tasks
https://github.com/funyin/kronos
job-scheduler koltin kotiln-backend kotlin-library kotlin-multiplatform
Last synced: 2 months ago
JSON representation
A kotlin multiplatform libary for scheduling persistent tasks
- Host: GitHub
- URL: https://github.com/funyin/kronos
- Owner: funyin
- License: apache-2.0
- Created: 2023-11-16T15:19:10.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-04-23T14:27:43.000Z (about 1 year ago)
- Last Synced: 2025-02-06T13:22:46.225Z (4 months ago)
- Topics: job-scheduler, koltin, kotiln-backend, kotlin-library, kotlin-multiplatform
- Language: HTML
- Homepage: https://funyin.github.io/Kronos/
- Size: 1.03 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Roadmap: docs/roadmap.md
Awesome Lists containing this project
README
[](https://github.com/funyin/Kronos/actions/workflows/test.yml) 
[](https://app.netlify.com/sites/kronos-kdock/deploys)# Overview
Welcome to Kronos.\
The persistent job scheduling library for kotlin multiplatform.
Published on maven central### Installation
```kts
implementation("com.funyinkash:kronos:0.0.3")
```### Summary
```kotlin
suspend fun main() {//Initialize
Kronos.init(
mongoConnectionString = "mongodb://localhost:27017",
redisConnectionString = "redis://localhost:6379"
)
//Register a Job
Kronos.register(SayHello)
//Schedule a one time job
Kronos.schedule(
SayHello.name,/*say-hello*/
startTime = Instant.now().plusSeconds(60).toEpochMilli(),
params = mapOf(
"firsName" to "Funyin",
"lastName" to "Kash"
),
)//Schedule a periodic job an get back the jobId
val jobId = Kronos.schedulePeriodic(
jobName = SayHello.name,
/*say-hello*/
// startTime = Instant.now().plusSeconds(60).toEpochMilli(),
periodic = Periodic.everyMinute(),
// periodic = Periodic.everyHour(minute = 5),
// periodic = Periodic.everyWeek(dayOfWeek = 7, hour = 4, minute = 2),
// periodic = Periodic.everyMonth(dayOfMonth = 12, hour = 4, minute = 2),
// periodic = Periodic.everyYear(month = 1, dayOfMonth = 7, hour = 4, minute = 2),
params = mapOf(
"firsName" to "Funyin",
"lastName" to "Kash"
),
)//Drop Job By Id
jobId?.let { Kronos.dropJobId(it) }
//Drop Job By Name
jobId?.let { Kronos.dropJob(SayHello.name) }Kronos.dropAll()
delay(1000 * 60 * 7)
}object SayHello : Job {
override val name: String
get() = "say-hello"override val retries: Int
get() = 2override suspend fun execute(cycleNumber: Int, params: Map): Boolean {
super.execute(cycleNumber, params)
println("Hello ${params["firsName"]} ${params["lastName"]} $cycleNumber")
return true
}}
```### Licence
Kronos is Licenced by [Apache 2.0 Licence](LICENSE.txt)