muesli-0.1.1.0: A simple document-oriented database

Copyright(c) 2015 Călin Ardelean
LicenseMIT
MaintainerCălin Ardelean <calinucs@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010
Extensions
  • MonoLocalBinds
  • TypeFamilies
  • FlexibleContexts
  • KindSignatures
  • ExplicitNamespaces

Database.Muesli.Backend.Types

Contents

Description

Generic backend interface types and classes.

This module is re-exported by other modules, like Database.Muesli.Handle.

Synopsis

Transaction log records

data TransRecord Source

This type represents a line in the transaction log file. There can be multiple lines for a single transaction, and the last one must be a Completed one. Other than that, the lines from multiple transactions can be mixed.

data LogRecord Source

Holds the metadata for a given document version.

Keys collected by the generic scrapper are stored in recReferences, recSortables, and recUniques. The recDocumentKey is generated by an IdSupply, while the recAddress and recSize are allocated by alloc. This work is done either by the primitive queries in Database.Muesli.Query, or by runQuery.

Instances

Generic backend interface

These classes are used by the machinary in Database.Muesli.State.

For an implementation, see the Database.Muesli.Backend.File module.

class (Show a, DbHandle (LogHandleOf a), DataHandle (DataHandleOf a)) => LogState a where Source

Provides stateful access to an abstract log file handle.

Associated Types

type LogHandleOf a :: * Source

type DataHandleOf a :: * Source

Methods

logHandle :: a -> LogHandleOf a Source

logInit :: MonadIO m => LogHandleOf a -> m a Source

logAppend :: MonadIO m => a -> [TransRecord] -> m a Source

logRead :: MonadIO m => a -> m (Maybe TransRecord) Source

class DbHandle a => DataHandle a where Source

Handle used to access serialized document data in the generic data file.

type DbPath = String Source

Generic path type. For instance, this can be a file path or an url.

class DbHandle a where Source

Generic handle interface.

Methods

openDb :: MonadIO m => DbPath -> m a Source

closeDb :: MonadIO m => a -> m () Source

withDb :: MonadIO m => DbPath -> (a -> IO b) -> m b Source

swapDb :: MonadIO m => DbPath -> DbPath -> m a Source