acid-state-0.14.3: Add ACID guarantees to any serializable Haskell data structure.

CopyrightPublicDomain
Maintainerlemmih@gmail.com
Portabilitynon-portable (uses GHC extensions)
Safe HaskellNone
LanguageHaskell2010

Data.Acid.Local

Description

AcidState container using a transaction log on disk. The term 'Event' is loosely used for transactions with ACID guarantees. 'Method' is loosely used for state operations without ACID guarantees (see Data.Acid.Core).

Synopsis

Documentation

openLocalState Source #

Arguments

:: (Typeable st, IsAcidic st) 
=> st

Initial state value. This value is only used if no checkpoint is found.

-> IO (AcidState st) 

Create an AcidState given an initial value.

This will create or resume a log found in the "state/[typeOf state]/" directory.

openLocalStateFrom Source #

Arguments

:: IsAcidic st 
=> FilePath

Location of the checkpoint and transaction files.

-> st

Initial state value. This value is only used if no checkpoint is found.

-> IO (AcidState st) 

Create an AcidState given a log directory and an initial value.

This will create or resume a log found in directory. Running two AcidState's from the same directory is an error but will not result in dataloss.

prepareLocalState Source #

Arguments

:: (Typeable st, IsAcidic st) 
=> st

Initial state value. This value is only used if no checkpoint is found.

-> IO (IO (AcidState st)) 

Create an AcidState given an initial value.

This will create or resume a log found in the "state/[typeOf state]/" directory. The most recent checkpoint will be loaded immediately but the AcidState will not be opened until the returned function is executed.

prepareLocalStateFrom Source #

Arguments

:: IsAcidic st 
=> FilePath

Location of the checkpoint and transaction files.

-> st

Initial state value. This value is only used if no checkpoint is found.

-> IO (IO (AcidState st)) 

Create an AcidState given an initial value.

This will create or resume a log found in directory. The most recent checkpoint will be loaded immediately but the AcidState will not be opened until the returned function is executed.

scheduleLocalUpdate' :: UpdateEvent event => LocalState (EventState event) -> event -> MVar (EventResult event) -> IO (IO ()) Source #

Same as scheduleLocalUpdate but does not immediately change the localCopy and return the result mvar - returns an IO action to do this instead. Take care to run actions of multiple Updates in the correct order as otherwise Queries will operate on outdated state.

scheduleLocalColdUpdate' :: LocalState st -> Tagged ByteString -> MVar ByteString -> IO (IO ()) Source #

Same as scheduleLocalColdUpdate but does not immediately change the localCopy and return the result mvar - returns an IO action to do this instead. Take care to run actions of multiple Updates in the correct order as otherwise Queries will operate on outdated state.

createCheckpointAndClose :: (SafeCopy st, Typeable st) => AcidState st -> IO () Source #

Save a snapshot to disk and close the AcidState as a single atomic action. This is useful when you want to make sure that no events are saved to disk after a checkpoint.

data LocalState st Source #

State container offering full ACID (Atomicity, Consistency, Isolation and Durability) guarantees.

Atomicity
State changes are all-or-nothing. This is what you'd expect of any state variable in Haskell and AcidState doesn't change that.
Consistency
No event or set of events will break your data invariants.
Isolation
Transactions cannot interfere with each other even when issued in parallel.
Durability
Successful transaction are guaranteed to survive system failure (both hardware and software).