[ANN] Initial release of Spider Queue Database
Announce: This database will be used as the simple binary file format for queuing requests. Ideally, rabbitmq would be be used but the client has not been implemented. (Basically, this is just a simple file format; if you want to see the haskell source, see the link below. Covers Data.Binary use, ByteStrings, decodeFile, encodeFile and some other basic binary file manipulations)
References
http://openbotlist.googlecode.com/svn/trunk/botlistprojects/botspider/spider/lib/haskell/src/Data/SpiderQueue/Queue.hs
instance Binary SpiderQueue where
put dbq = do
BinaryPut.putWord16be (magicNumberA dbq)
BinaryPut.putWord16be (magicNumberB dbq)
BinaryPut.putWord16be (majorVers dbq)
BinaryPut.putWord16be (minorVers dbq)
BinaryPut.putWord32be (queueSize dbq)
-- @see mapM: Monad m => (a -> m b) -> [a] -> m [b]
(mapM_ put (queue dbq))
get = do
magicnumbera <- BinaryGet.getWord16be
magicnumberb <- BinaryGet.getWord16be
major <- BinaryGet.getWord16be
minor <- BinaryGet.getWord16be
len <- BinaryGet.getWord32be
-- *******************************
-- Get the remaining byte string data,
-- So that we can use lazy bytestring to load to load the
-- the data types.
-- Also: queueData <- forM [1..len] (const (get :: Get QueueObject))
-- *******************************
queueData <- replicateM (fromIntegral len) (get :: Get QueueObject)
return (SpiderQueue {magicNumberA=magicnumbera,
magicNumberB=magicnumberb,
majorVers=major,
minorVers=minor,
queueSize=len,
queue=queueData
})
References
http://openbotlist.googlecode.com/svn/trunk/botlistprojects/botspider/spider/lib/haskell/src/Data/SpiderQueue/Queue.hs
Comments