Server-side stub impl for notify-due-items

This commit is contained in:
Eike Kettner
2020-04-19 20:31:28 +02:00
parent e97e0db45c
commit ad772c0c25
16 changed files with 562 additions and 37 deletions

View File

@ -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,

View File

@ -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

View File

@ -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"))
}

View File

@ -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))
}