mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Remove store dependency from scheduler api
This commit is contained in:
@ -8,7 +8,6 @@ package docspell.scheduler
|
||||
|
||||
import docspell.common._
|
||||
import docspell.logging.Logger
|
||||
import docspell.store.Store
|
||||
|
||||
trait Context[F[_], A] { self =>
|
||||
|
||||
@ -22,8 +21,6 @@ trait Context[F[_], A] { self =>
|
||||
|
||||
def setProgress(percent: Int): F[Unit]
|
||||
|
||||
def store: Store[F]
|
||||
|
||||
def isLastRetry: F[Boolean]
|
||||
|
||||
def map[C](f: A => C): Context[F, C]
|
||||
|
@ -10,13 +10,12 @@ import cats.effect._
|
||||
import fs2.Stream
|
||||
|
||||
import docspell.common.Ident
|
||||
import docspell.store.records.RJob
|
||||
|
||||
trait Scheduler[F[_]] {
|
||||
|
||||
def config: SchedulerConfig
|
||||
|
||||
def getRunning: F[Vector[RJob]]
|
||||
def getRunning: F[Vector[Job[String]]]
|
||||
|
||||
def requestCancel(jobId: Ident): F[Boolean]
|
||||
|
||||
|
@ -13,7 +13,7 @@ import docspell.store.records.RJob
|
||||
class ContextImpl[F[_]: Functor, A](
|
||||
val args: A,
|
||||
val logger: Logger[F],
|
||||
val store: Store[F],
|
||||
store: Store[F],
|
||||
val config: SchedulerConfig,
|
||||
val jobId: Ident
|
||||
) extends Context[F, A] {
|
||||
|
@ -64,8 +64,23 @@ final class SchedulerImpl[F[_]: Async](
|
||||
.drain
|
||||
)
|
||||
|
||||
def getRunning: F[Vector[RJob]] =
|
||||
state.get.flatMap(s => QJob.findAll(s.getRunning, store))
|
||||
def getRunning: F[Vector[Job[String]]] =
|
||||
state.get
|
||||
.flatMap(s => QJob.findAll(s.getRunning, store))
|
||||
.map(
|
||||
_.map(rj =>
|
||||
Job(
|
||||
rj.id,
|
||||
rj.task,
|
||||
rj.group,
|
||||
rj.args,
|
||||
rj.subject,
|
||||
rj.submitter,
|
||||
rj.priority,
|
||||
rj.tracker
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def requestCancel(jobId: Ident): F[Boolean] =
|
||||
logger.info(s"Scheduler requested to cancel job: ${jobId.id}") *>
|
||||
|
Reference in New Issue
Block a user