Safe Haskell | None |
---|---|
Language | Haskell2010 |
RON File Storage. For usage, see RON.Storage.IO.
Synopsis
- class (ReplicatedAsObject a, Typeable a) => Collection a where
- collectionName :: CollectionName
- fallbackParse :: MonadE m => UUID -> ByteStringL -> m (Object a)
- data CollectionDocId = Collection a => CollectionDocId (DocId a)
- type CollectionName = FilePath
- newtype DocId a = DocId FilePath
- data Document a = Document {}
- type DocVersion = FilePath
- class (ReplicaClock m, MonadE m) => MonadStorage m where
- getCollections :: m [CollectionName]
- getDocuments :: Collection a => m [DocId a]
- getDocumentVersions :: Collection a => DocId a -> m [DocVersion]
- saveVersionContent :: Collection a => DocId a -> DocVersion -> ByteStringL -> m ()
- loadVersionContent :: Collection a => DocId a -> DocVersion -> m ByteStringL
- deleteVersion :: Collection a => DocId a -> DocVersion -> m ()
- changeDocId :: Collection a => DocId a -> DocId a -> m ()
- createDocument :: (Collection a, MonadStorage m) => Object a -> m ()
- decodeDocId :: DocId a -> Maybe (Bool, UUID)
- docIdFromUuid :: UUID -> DocId a
- loadDocument :: (Collection a, MonadStorage m) => DocId a -> m (Document a)
- modify :: (Collection a, MonadStorage m) => DocId a -> StateT (Object a) m () -> m (Object a)
- readVersion :: MonadStorage m => Collection a => DocId a -> DocVersion -> m (Object a, IsTouched)
Documentation
class (ReplicatedAsObject a, Typeable a) => Collection a where Source #
A type that intended to be put in a separate collection must define a Collection instance.
collectionName :: CollectionName Source #
fallbackParse :: MonadE m => UUID -> ByteStringL -> m (Object a) Source #
Called when RON parser fails.
data CollectionDocId Source #
Collection a => CollectionDocId (DocId a) |
type CollectionName = FilePath Source #
Collection (directory name)
Document identifier (directory name), should be a RON-Base32-encoded RON-UUID.
Result of DB reading, loaded document with information about its versions
type DocVersion = FilePath Source #
Document version identifier (file name)
class (ReplicaClock m, MonadE m) => MonadStorage m where Source #
Storage backend interface
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 -> ByteStringL -> m () Source #
Must create collection and document if not exist
loadVersionContent :: Collection a => DocId a -> DocVersion -> m ByteStringL Source #
deleteVersion :: Collection a => DocId a -> DocVersion -> m () Source #
changeDocId :: Collection a => DocId a -> DocId a -> m () Source #
Instances
MonadStorage Storage Source # | |
Defined in RON.Storage.IO getCollections :: Storage [CollectionName] Source # getDocuments :: Collection a => Storage [DocId a] Source # getDocumentVersions :: Collection a => DocId a -> Storage [DocVersion] Source # saveVersionContent :: Collection a => DocId a -> DocVersion -> ByteStringL -> Storage () Source # loadVersionContent :: Collection a => DocId a -> DocVersion -> Storage ByteStringL Source # deleteVersion :: Collection a => DocId a -> DocVersion -> Storage () Source # changeDocId :: Collection a => DocId a -> DocId a -> Storage () Source # |
createDocument :: (Collection a, MonadStorage m) => Object a -> m () Source #
Create document assuming it doesn't exist yet.
Try decode UUID from a file name
docIdFromUuid :: UUID -> DocId a Source #
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