Skip to content

Commit

Permalink
add runOnce to JobRunner
Browse files Browse the repository at this point in the history
  • Loading branch information
angryziber committed Feb 1, 2024
1 parent 435176a commit 43ed571
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* oauth: AppleOAuthClient updated and tested
* oauth: JWT helper class introduced
* jdbc: introduced db.upsertBatch()
* jobs: runOnce() introduced for convenience

# 1.6.4
* core: added common value types for Email, Phone, and Password, also StringValue base class
Expand Down
2 changes: 2 additions & 0 deletions jobs/src/JobRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ open class JobRunner(

open suspend fun run(job: Job) = job.run()

open fun runOnce(job: Job) = workerPool.submit { runInTransaction(job, UNDISPATCHED) }

open fun schedule(job: Job, delay: Long, period: Long, unit: TimeUnit) {
val startAt = LocalDateTime.now().plus(delay, unit.toChronoUnit())
log.info("${job.name} will start at $startAt and run every $period $unit")
Expand Down
2 changes: 1 addition & 1 deletion sample/test/klite/jdbc/JdbcExtensionsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ open class JdbcExtensionsTest: TempTableDBTest() {
val data = SomeData("World", 37)
db.insert(table, data.toValues())

db.update(table, mapOf("world" to 39), "id" to data.id)
expect(db.update(table, mapOf("world" to 39), "id" to data.id)).toEqual(1)
expect(db.select(table, data.id) { create<SomeData>() }).toEqual(data.copy(world = 39))

db.delete(table, "world" to 39)
Expand Down

0 comments on commit 43ed571

Please sign in to comment.