-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A high performance in memory and LevelDB backend for powerqueue -- -- A high performance in memory and LevelDB backend for powerqueue @package powerqueue-levelmem @version 0.1.1.0 module Data.PowerQueue.Backend.LevelMem -- | Create a new data container for in memory job tracking and leveldb -- disk persistence. Provide a FilePath for storing the data, an -- Int as maximum queue size and a JobEncoding for -- individual job encoding. withLevelMem :: LevelMemCfg j -> (LevelMem j -> IO a) -> IO a data LevelMemCfg j LevelMemCfg :: !FilePath -> !Int -> !(JobEncoding j) -> !InProgressCfg -> LevelMemCfg j -- | directory for persistence [lmc_storageDir] :: LevelMemCfg j -> !FilePath -- | maximum size of queue, succeeding enqueues will block [lmc_maxQueueSize] :: LevelMemCfg j -> !Int -- | binary encoding of jobs [lmc_jobEncoding] :: LevelMemCfg j -> !(JobEncoding j) -- | how should in progress jobs be handled after a restart while loading -- from disk [lmc_inProgressRecovery] :: LevelMemCfg j -> !InProgressCfg -- | Behavoir for in progress jobs after loading the state from disk on -- launch data InProgressCfg -- | mark the job as in progress IpRecover :: InProgressCfg -- | add the job to the queue IpRestart :: InProgressCfg -- | discard the job IpForget :: InProgressCfg -- | Binary encoding of a single job. Note that it is highly recommended to -- use a backwards compatible decoder, otherwise the persistent state can -- not be read. You could use safecopy or an appropriate cereal, binary, -- aeson or other decoding. data JobEncoding j JobEncoding :: (j -> ByteString) -> (ByteString -> Either String j) -> JobEncoding j [j_encode] :: JobEncoding j -> j -> ByteString [j_decode] :: JobEncoding j -> ByteString -> Either String j -- | The data container for tracking jobs and persisting them to disk data LevelMem j data JobStatus -- | job is enqueued, not being worked on JQueued :: JobStatus -- | job currently being worked on JInProgress :: JobStatus -- | Get a snapshot of the current state of all jobs. getJobStatusMap :: LevelMem j -> IO [(j, JobStatus)] -- | Get the job status for a job. Note that this is a potentially -- expensive operation as all known jobs must be traversed. A more -- efficient handling would be to call getJobStatusMap once -- beforce launching the worker and then tracking status manually within -- the worker. getJobStatus :: Eq j => j -> LevelMem j -> IO (Maybe JobStatus) -- | Create a queue backend from LevelMem newLevelMemBackend :: LevelMem j -> QueueBackend j instance GHC.Classes.Eq Data.PowerQueue.Backend.LevelMem.JobStatus instance GHC.Show.Show Data.PowerQueue.Backend.LevelMem.JobStatus