chore(jobsystem): add dependencies, work on first model defs

This commit is contained in:
Sarah Vaupel 2023-11-02 20:49:05 +00:00
parent 44c1d98cc0
commit 36a53d3dae
9 changed files with 89 additions and 12 deletions

View File

@ -3,6 +3,7 @@
-- SPDX-License-Identifier: AGPL-3.0-or-later
-- Jobs to be executed as soon as possible in the background (so not to delay HTTP-responses, or triggered by cron-system without associated HTTP-Request)
-- part of the *old* job system
QueuedJob
content Value -- JSON-encoded description of the work to be done (send an email to "test@example.org", find all recipients for a certain notifications and queue one new job each, distribute all submissions for a sheet to correctors, ...)
creationInstance InstanceId -- multiple uni2work-instances access the same database, record which instance created this job for debugging purposes
@ -15,6 +16,7 @@ QueuedJob
-- Jobs are deleted from @QueuedJob@ after they are executed successfully and recorded in @CronLastExec@
-- There is a Cron-system that, at set intervals, queries the database for work to be done in the background (i.e. if a lecturer has set a sheet's submissions to be automatically distributed and the submission deadline passed since the last check, then queue a new job to actually do the distribution)
-- For the cron-system to determine whether a job needs to be done it needs to know if and when it was last (or ever) executed (i.e. a sheet's submissions should not be distributed twice)
-- part of the *old* job system
CronLastExec
job Value -- JSON-encoded description of work done
time UTCTime -- When was the job executed
@ -22,6 +24,7 @@ CronLastExec
UniqueCronLastExec job
deriving Generic
-- part of the *old* job system
TokenBucket
ident TokenBucketIdent
lastValue Int64

5
models/jobsystem.model Normal file
View File

@ -0,0 +1,5 @@
-- Jobs to be fetched and distributed to the workers by the scheduler
-- part of the *new* job system
JobMeta
occurrence JobOccurrence default='{"dnf-terms":[]}' -- when should the job be executed? (Possibly recurring)
deriving Eq Ord Show Generic

View File

@ -187,6 +187,9 @@ dependencies:
- either
- xlsx
- jobsys
- occurrence
- segmented
- haskell-nf
other-extensions:
- GeneralizedNewtypeDeriving
- IncoherentInstances

View File

@ -262,9 +262,10 @@ import Data.MultiSet as Import (MultiSet)
import Data.MonoTraversable.Keys as Import
import Control.Monad.Trans.RWS (RWST)
import Data.Occurrence as Import (Occurrence)
type MForm m = RWST (Maybe (Env, FileEnv), HandlerSite m, [Lang]) Enctype Ints m

View File

@ -6,9 +6,12 @@ module JobSystem
(
) where
-- TODO: add gitlab.uniworx.de/barth/jobsys as dependency to be able to import JobSchedulerWorld and its function
import Jobsys.JobSystem
-- import Jobsys.JobSystem
-- TODO: define JobSchedulerWorld instance for managing job workers, scheduler, and communation in-between
-- instance JobSchedulerWorld world where
-- ...
-- instance JobSchedulerWorld _world where
-- type Priorities _world = Int
-- type JobId _world = ()
-- type Ressource _world = ()
-- type Version _world = ()
-- type WorkerId _world = ()

View File

@ -31,3 +31,4 @@ import Model.Types.Lms as Types
import Model.Types.Avs as Types
import Model.Types.Communication as Types
import Model.Types.SystemMessage as Types
import Model.Types.Jobsystem as Types

View File

@ -0,0 +1,9 @@
module Model.Types.Jobsystem
( JobOccurrence
) where
import Import.NoModel
type JobOccurrence = Occurrence LocalTime () -- latter is specialtime; not used yet
derivePersistFieldJSON ''Occurrence LocalTime ()

View File

@ -121,9 +121,22 @@ extra-deps:
- persistent-postgresql-2.13.0.3@sha256:43384bf8ed9c931c673e6abb763c8811113d1b7004095faaae1eb42e2cd52d8f,3601
- git: https://gitlab.uniworx.de/barth/jobsys.git
commit: 027e9b9a6c38c4f1f1dfe1782726887208084184
commit: f7aa8c32bb28acfab72863c07184154caff75dcd
subdirs:
- jobsys
- git: https://gitlab.uniworx.de/barth/occurrence.git
commit: ac4babd9a73814332800460ab7ae469285355207
subdirs:
- occurrence
- git: https://gitlab.uniworx.de/barth/segmented.git
commit: c790d4d350536e21cbbe421000122390ac2f62d0
subdirs:
- segmented
- git: https://github.com/savau/haskell-nf.git
commit: 7f1a8715f41778a67655745ce43334328888020b
subdirs:
- haskell-nf
resolver: lts-18.0
allow-newer: true

View File

@ -536,18 +536,57 @@ packages:
original:
hackage: persistent-postgresql-2.13.0.3@sha256:43384bf8ed9c931c673e6abb763c8811113d1b7004095faaae1eb42e2cd52d8f,3601
- completed:
commit: 027e9b9a6c38c4f1f1dfe1782726887208084184
commit: f7aa8c32bb28acfab72863c07184154caff75dcd
git: https://gitlab.uniworx.de/barth/jobsys.git
name: jobsys
pantry-tree:
sha256: 1325749c3c5dce631b095567dc8729ac20831058aa0c7486452a36afee0a775a
size: 342
sha256: ca0c2530b5befa4bb0160fdfd17095ed0bfacc85a622ca8a60949e4c3a89588a
size: 601
subdir: jobsys
version: 0.0.1
version: 0.1.0
original:
commit: 027e9b9a6c38c4f1f1dfe1782726887208084184
commit: f7aa8c32bb28acfab72863c07184154caff75dcd
git: https://gitlab.uniworx.de/barth/jobsys.git
subdir: jobsys
- completed:
commit: ac4babd9a73814332800460ab7ae469285355207
git: https://gitlab.uniworx.de/barth/occurrence.git
name: occurrence
pantry-tree:
sha256: 93eeceb13a73458fb06a065ff686bc127ac6e0acef6503917cd9edb0050a3764
size: 301
subdir: occurrence
version: 0.1.0
original:
commit: ac4babd9a73814332800460ab7ae469285355207
git: https://gitlab.uniworx.de/barth/occurrence.git
subdir: occurrence
- completed:
commit: c790d4d350536e21cbbe421000122390ac2f62d0
git: https://gitlab.uniworx.de/barth/segmented.git
name: segmented
pantry-tree:
sha256: 562c5fdc28a876373f7340427aa6d79b623fe6095c730d7848a2d11cf8d7b3ca
size: 236
subdir: segmented
version: 0.1.0
original:
commit: c790d4d350536e21cbbe421000122390ac2f62d0
git: https://gitlab.uniworx.de/barth/segmented.git
subdir: segmented
- completed:
commit: 7f1a8715f41778a67655745ce43334328888020b
git: https://github.com/savau/haskell-nf.git
name: haskell-nf
pantry-tree:
sha256: 01808a6584d7310d1df4ba90c728d10b35646ffcb711ab6f12b27ed9fbbb311f
size: 314
subdir: haskell-nf
version: 0.3.1
original:
commit: 7f1a8715f41778a67655745ce43334328888020b
git: https://github.com/savau/haskell-nf.git
subdir: haskell-nf
snapshots:
- completed:
sha256: c632012da648385b9fa3c29f4e0afd56ead299f1c5528ee789058be410e883c0