The control structure at the very center of acid-state. This module provides access to a mutable state through methods. No efforts towards durability, checkpointing or sharding happens at this level. Important things to keep in mind in this module: * We don't distinguish between updates and queries. * We allow direct access to the core state as well as through events.
Moduleacid-state-0.16.1.4Haskell2010
Data.Acid.Core
Low-level controls for transaction-based state changes. This module defines structures and tools for running state modifiers indexed either by an Method or a serialized Method. This module should rarely be used directly although the Method class is needed when defining events manually.
The term 'Event' is loosely used for transactions with ACID guarantees. 'Method' is loosely used for state operations without ACID guarantees
- 6 types
- 1 class
- 19 values
- Packageacid-state-0.16.1.4
- Exports26
- LanguageHaskell2010
- LicenceLicenseRef-PublicDomain
- SourceCore.hs
The basic Method class. Each Method has an indexed result type and a unique tag.
Associated types
type family MethodResult evtype family MethodState ev
Methods
methodTag :: ev -> Tag
Method container structure that hides the exact type of the method.
Constructors
Method :: Method method => MethodBody method -> MethodSerialiser method -> MethodContainer (MethodState method)
mkCore :: [MethodContainer st]List of methods capable of modifying the state.
-> stInitial state value.
-> IO (Core st)
Construct a new Core using an initial state and a list of Methods.
Mark Core as closed. Any subsequent use will throw an exception.
Access the state and then mark the Core as closed. Any subsequent use will throw an exception.
Modify the state component. The resulting state is ensured to be in WHNF.
Modify the state component. The resulting state is ensured to be in WHNF.
Access the state component.
Find the state action that corresponds to an in-memory method.
Find the state action and serialiser that correspond to an in-memory method.
Find the state action that corresponds to a tagged and serialized method.
Apply an in-memory method to the state.
Execute a method as given by a type identifier and an encoded string. The exact format of the encoded string depends on the type identifier. Results are encoded and type tagged before they're handed back out. This function is used when running events from a log-file or from another server. Events that originate locally are most likely executed with the faster runHotMethod.
Collection of Methods indexed by a Tag.
Construct a MethodMap from a list of Methods using their associated tag.
Interface for (de)serialising values of type a.
A Serialiser { serialiserEncode, serialiserDecode } must
satisfy the round-trip property:
forall x . serialiserDecode (serialiserEncode x) == Right xConstructors
SerialiserserialiserEncode :: a -> ByteStringSerialise a value to a bytestring.
serialiserDecode :: ByteString -> Either String aDeserialise a value, generating a string error message on failure.
Default implementation of Serialiser interface using SafeCopy.
Interface for (de)serialising a method, namely Serialisers for its arguments type and its result type.
Constructors
MethodSerialisermethodSerialiser :: Serialiser methodresultSerialiser :: Serialiser (MethodResult method)
safeCopyMethodSerialiser :: (SafeCopy method, SafeCopy (MethodResult method)) => MethodSerialiser methodDefault implementation of MethodSerialiser interface using SafeCopy.
Encode the arguments of a method using the given serialisation strategy.
Decode the arguments of a method using the given serialisation strategy.
Encode the result of a method using the given serialisation strategy.
Decode the result of a method using the given serialisation strategy.