mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Server-side stub impl for notify-due-items
This commit is contained in:
@ -2,7 +2,7 @@ package docspell.joex
|
||||
|
||||
import cats.implicits._
|
||||
import cats.effect._
|
||||
import docspell.common.{Ident, NodeType, ProcessItemArgs}
|
||||
import docspell.common._
|
||||
import docspell.joex.hk._
|
||||
import docspell.joex.process.ItemHandler
|
||||
import docspell.joex.scheduler._
|
||||
@ -75,6 +75,13 @@ object JoexAppImpl {
|
||||
ItemHandler.onCancel[F]
|
||||
)
|
||||
)
|
||||
.withTask(
|
||||
JobTask.json(
|
||||
NotifyDueItemsArgs.taskName,
|
||||
NotifyDueItemsTask[F],
|
||||
NotifyDueItemsTask.onCancel[F]
|
||||
)
|
||||
)
|
||||
.withTask(
|
||||
JobTask.json(
|
||||
HouseKeepingTask.taskName,
|
||||
|
@ -17,12 +17,12 @@ object HouseKeepingTask {
|
||||
|
||||
def apply[F[_]: Sync](cfg: Config): Task[F, Unit, Unit] =
|
||||
Task
|
||||
.log[F](_.info(s"Running house-keeping task now"))
|
||||
.log[F, Unit](_.info(s"Running house-keeping task now"))
|
||||
.flatMap(_ => CleanupInvitesTask(cfg.houseKeeping.cleanupInvites))
|
||||
.flatMap(_ => CleanupJobsTask(cfg.houseKeeping.cleanupJobs))
|
||||
|
||||
def onCancel[F[_]: Sync]: Task[F, Unit, Unit] =
|
||||
Task.log(_.warn("Cancelling house-keeping task"))
|
||||
Task.log[F, Unit](_.warn("Cancelling house-keeping task"))
|
||||
|
||||
def periodicTask[F[_]: Sync](ce: CalEvent): F[RPeriodicTask] =
|
||||
RPeriodicTask
|
||||
|
@ -0,0 +1,23 @@
|
||||
package docspell.joex.hk
|
||||
|
||||
import cats.implicits._
|
||||
import cats.effect._
|
||||
|
||||
import docspell.common._
|
||||
import docspell.joex.scheduler.Task
|
||||
|
||||
object NotifyDueItemsTask {
|
||||
|
||||
def apply[F[_]: Sync](): Task[F, NotifyDueItemsArgs, Unit] =
|
||||
Task { ctx =>
|
||||
for {
|
||||
now <- Timestamp.current[F]
|
||||
_ <- ctx.logger.info(s" $now")
|
||||
_ <- ctx.logger.info(s"Removed $ctx")
|
||||
} yield ()
|
||||
}
|
||||
|
||||
def onCancel[F[_]: Sync]: Task[F, NotifyDueItemsArgs, Unit] =
|
||||
Task.log(_.warn("Cancelling notify-due-items task"))
|
||||
|
||||
}
|
@ -55,6 +55,6 @@ object Task {
|
||||
def setProgress[F[_]: Sync, A, B](n: Int)(data: B): Task[F, A, B] =
|
||||
Task(_.setProgress(n).map(_ => data))
|
||||
|
||||
def log[F[_]](f: Logger[F] => F[Unit]): Task[F, Unit, Unit] =
|
||||
def log[F[_], A](f: Logger[F] => F[Unit]): Task[F, A, Unit] =
|
||||
Task(ctx => f(ctx.logger))
|
||||
}
|
||||
|
Reference in New Issue
Block a user