Skip to content

osoykan/db-scheduler-additions

Repository files navigation

Additions For Db Scheduler

This project aims to add support for additional databases and a Ktor UI plugin for the Db Scheduler project. If you find any bug please report it.

UI Ktor Plugin

This package uses db-scheduler-ui and provides a ktor plugin to interact with.

implementation("io.github.osoykan:db-scheduler-ui-ktor:$version")
install(DbSchedulerUI) {
  routePath = "/db-scheduler"
  scheduler = { get<Scheduler>() } // assuming Koin is in place, but you can provide your instance to the functions.
  dataSource = { get<DataSource>() }
  enabled = true
  taskData = true
}

Warning

Enabling taskData might cause a peak in memory usage. The issue was discussed at bekk/db-scheduler-ui#121

Couchbase

implementation("io.github.osoykan:db-scheduler-couchbase:$version")
scheduler {
  val couchbase = Couchbase(cluster, "bucket-name", "collection-name")
  couchbase.ensureCollectionExists()

  database(couchbase)
  knownTasks(*tasks.toTypedArray())
  startupTasks(*startupTasks.toTypedArray())
  name(name)
  clock(clock)
  shutdownMaxWait(1.seconds)
  fixedThreadPoolSize(5)
  corePoolSize(1)
  heartbeatInterval(2.seconds)
  executeDue(2.seconds)
  deleteUnresolvedAfter(1.seconds)
  logLevel(LogLevel.TRACE)
  logStackTrace(true)
  shutdownMaxWait(1.minutes)
  numberOfMissedHeartbeatsBeforeDead(3)
  listeners(emptyList())
  meterRegistry(PrometheusMeterRegistry(PrometheusConfig.DEFAULT))
}.also {
  it.start()
}

Mongo

implementation("io.github.osoykan:db-scheduler-mongo:$version")
scheduler {
  val mongo = Mongo(client, "database-name", "collection-name")
  mongo.ensureCollectionExists()

  database(mongo)
  knownTasks(*tasks.toTypedArray())
  startupTasks(*startupTasks.toTypedArray())
  name(name)
  clock(clock)
  shutdownMaxWait(1.seconds)
  fixedThreadPoolSize(5)
  corePoolSize(1)
  heartbeatInterval(2.seconds)
  executeDue(2.seconds)
  deleteUnresolvedAfter(1.seconds)
  logLevel(LogLevel.TRACE)
  logStackTrace(true)
  shutdownMaxWait(1.minutes)
  numberOfMissedHeartbeatsBeforeDead(3)
  listeners(emptyList())
  meterRegistry(PrometheusMeterRegistry(PrometheusConfig.DEFAULT))
}.also {
  it.start()
}