ron-0.3: RON, RON-RDT, and RON-Schema

Safe HaskellNone
LanguageHaskell2010

RON.Storage

Description

RON File Storage. For usage, see RON.Storage.IO.

Synopsis

Documentation

class ReplicatedAsObject a => Collection a where Source #

A type that intended to be put in a separate collection must define a Collection instance.

Minimal complete definition

collectionName

Methods

collectionName :: CollectionName Source #

fallbackParse :: UUID -> ByteString -> Either String (Object a) Source #

Called when RON parser fails.

type CollectionName = FilePath Source #

Collection (directory name)

newtype DocId a Source #

Document identifier (directory name), should be a RON-Base32-encoded RON-UUID.

Constructors

DocId FilePath 
Instances
Collection a => Show (DocId a) Source # 
Instance details

Defined in RON.Storage

Methods

showsPrec :: Int -> DocId a -> ShowS #

show :: DocId a -> String #

showList :: [DocId a] -> ShowS #

data Document a Source #

Result of DB reading, loaded document with information about its versions

Constructors

Document 

Fields

Instances
Show (Document a) Source # 
Instance details

Defined in RON.Storage

Methods

showsPrec :: Int -> Document a -> ShowS #

show :: Document a -> String #

showList :: [Document a] -> ShowS #

type DocVersion = FilePath Source #

Document version identifier (file name)

class (ReplicaClock m, MonadError String m) => MonadStorage m where Source #

Storage backend interface

Methods

getCollections :: m [CollectionName] Source #

getDocuments :: Collection a => m [DocId a] Source #

Must return [] for non-existent collection

getDocumentVersions :: Collection a => DocId a -> m [DocVersion] Source #

Must return [] for non-existent document

saveVersionContent :: Collection a => DocId a -> DocVersion -> ByteString -> m () Source #

Must create collection and document if not exist

loadVersionContent :: Collection a => DocId a -> DocVersion -> m ByteString Source #

deleteVersion :: Collection a => DocId a -> DocVersion -> m () Source #

changeDocId :: Collection a => DocId a -> DocId a -> m () Source #

createDocument :: (Collection a, MonadStorage m) => Object a -> m () Source #

Create document assuming it doesn't exist yet.

decodeDocId Source #

Arguments

:: DocId a 
-> Maybe (Bool, UUID)

Bool = is document id a valid UUID encoding

Try decode UUID from a file name

loadDocument :: (Collection a, MonadStorage m) => DocId a -> m (Document a) Source #

Load all versions of a document

modify :: (Collection a, MonadStorage m) => DocId a -> StateT (Object a) m () -> m (Object a) Source #

Load document, apply changes and put it back to storage

readVersion :: MonadStorage m => Collection a => DocId a -> DocVersion -> m (Object a, IsTouched) Source #

Load document version as an object