Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data AcidState st = AcidState {
- _scheduleUpdate :: forall event. (UpdateEvent event, EventState event ~ st) => event -> IO (MVar (EventResult event))
- scheduleColdUpdate :: Tagged ByteString -> IO (MVar ByteString)
- _query :: forall event. (QueryEvent event, EventState event ~ st) => event -> IO (EventResult event)
- queryCold :: Tagged ByteString -> IO ByteString
- createCheckpoint :: IO ()
- createArchive :: IO ()
- closeAcidState :: IO ()
- acidSubState :: AnyState st
- scheduleUpdate :: UpdateEvent event => AcidState (EventState event) -> event -> IO (MVar (EventResult event))
- groupUpdates :: UpdateEvent event => AcidState (EventState event) -> [event] -> IO ()
- update :: UpdateEvent event => AcidState (EventState event) -> event -> IO (EventResult event)
- update' :: (UpdateEvent event, MonadIO m) => AcidState (EventState event) -> event -> m (EventResult event)
- query :: QueryEvent event => AcidState (EventState event) -> event -> IO (EventResult event)
- query' :: (QueryEvent event, MonadIO m) => AcidState (EventState event) -> event -> m (EventResult event)
- mkAnyState :: Typeable sub_st => sub_st st -> AnyState st
- downcast :: (Typeable sub, Typeable st) => AcidState st -> sub st
Documentation
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 unexpected system shutdowns (both those caused by hardware and software).
AcidState | |
|
scheduleUpdate :: UpdateEvent event => AcidState (EventState event) -> event -> IO (MVar (EventResult event)) Source #
Issue an Update event and return immediately. The event is not durable
before the MVar has been filled but the order of events is honored.
The behavior in case of exceptions is exactly the same as for update
.
If EventA is scheduled before EventB, EventA will be executed before EventB:
do scheduleUpdate acid EventA scheduleUpdate acid EventB
groupUpdates :: UpdateEvent event => AcidState (EventState event) -> [event] -> IO () Source #
Schedule multiple Update events and wait for them to be durable, but throw away their results. This is useful for importing existing datasets into an AcidState.
update :: UpdateEvent event => AcidState (EventState event) -> event -> IO (EventResult event) Source #
Issue an Update event and wait for its result. Once this call returns, you are guaranteed that the changes to the state are durable. Events may be issued in parallel.
It's a run-time error to issue events that aren't supported by the AcidState.
update' :: (UpdateEvent event, MonadIO m) => AcidState (EventState event) -> event -> m (EventResult event) Source #
Same as update
but lifted into any monad capable of doing IO.
query :: QueryEvent event => AcidState (EventState event) -> event -> IO (EventResult event) Source #
Issue a Query event and wait for its result. Events may be issued in parallel.
query' :: (QueryEvent event, MonadIO m) => AcidState (EventState event) -> event -> m (EventResult event) Source #
Same as query
but lifted into any monad capable of doing IO.
mkAnyState :: Typeable sub_st => sub_st st -> AnyState st Source #