powerqueue-levelmem-0.1.1.0: A high performance in memory and LevelDB backend for powerqueue

Safe HaskellNone
LanguageHaskell2010

Data.PowerQueue.Backend.LevelMem

Contents

Synopsis

Data container

withLevelMem :: LevelMemCfg j -> (LevelMem j -> IO a) -> IO a Source #

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.

data LevelMemCfg j Source #

Constructors

LevelMemCfg 

Fields

data InProgressCfg Source #

Behavoir for in progress jobs after loading the state from disk on launch

Constructors

IpRecover

mark the job as in progress

IpRestart

add the job to the queue

IpForget

discard the job

data JobEncoding j Source #

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.

Constructors

JobEncoding 

data LevelMem j Source #

The data container for tracking jobs and persisting them to disk

data JobStatus Source #

Constructors

JQueued

job is enqueued, not being worked on

JInProgress

job currently being worked on

getJobStatusMap :: LevelMem j -> IO [(j, JobStatus)] Source #

Get a snapshot of the current state of all jobs.

getJobStatus :: Eq j => j -> LevelMem j -> IO (Maybe JobStatus) Source #

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.

Actual backend for powerqueue

newLevelMemBackend :: LevelMem j -> QueueBackend j Source #

Create a queue backend from LevelMem