chore(jobsystem): add ressource model representation

This commit is contained in:
Sarah Vaupel 2023-11-30 00:19:47 +00:00
parent c81bc149a9
commit ac1e272fb5
2 changed files with 24 additions and 0 deletions

View File

@ -4,6 +4,7 @@
JobMeta
occurrence JobOccurrence -- When should the job be executed?
-- (Possibly recurring)
ressources JobRessources
deriving Eq Ord Show Generic
-- Actual job to be fetched and executed by the workers

View File

@ -1,5 +1,6 @@
module Model.Types.Jobsystem
( JobOccurrence(..)
, JobRessource(..), JobRessources(..)
) where
import Import.NoModel
@ -16,3 +17,25 @@ deriveJSON defaultOptions
, unwrapUnaryRecords = True
} ''JobOccurrence
derivePersistFieldJSON ''JobOccurrence
data JobRessource
= JobResCPU
| JobResMemory
| JobResPrinter
deriving (Eq, Ord, Enum, Bounded, Read, Show, Generic)
deriving anyclass (Universe, Finite, NFData)
nullaryPathPiece ''JobRessource $ camelToPathPiece' 2
pathPieceJSON ''JobRessource
pathPieceJSONKey ''JobRessource
newtype JobRessources = JobRessources { jobRessources :: Map JobRessource Double }
deriving (Eq, Ord, Read, Show, Generic)
deriving anyclass (NFData)
deriveJSON defaultOptions
{ tagSingleConstructors = False
, unwrapUnaryRecords = True
} ''JobRessources
derivePersistFieldJSON ''JobRessources