happstack-state-0.4.1: Event-based distributed state.Source codeContentsIndex
Happstack.State.Transaction
Synopsis
type ExceptionT = SomeException
logMT :: Priority -> String -> IO ()
getTime :: Integral epochTime => AnyEv epochTime
getEventClockTime :: AnyEv ClockTime
getEventId :: Integral txId => AnyEv txId
data GetCheckpointState = GetCheckpointState
newtype SetCheckpointState = SetCheckpointState ByteString
type TypeString = String
data EventHandler where
UpdateHandler :: UpdateEvent ev res => (TxContext -> ev -> IO res) -> (ev -> IO res) -> (Object -> ev) -> EventHandler
QueryHandler :: QueryEvent ev res => (ev -> IO res) -> (Object -> ev) -> EventHandler
type EventMap = Map TypeString EventHandler
data EmitInternal = EmitInternal EventMap
emitRef :: IORef EmitInternal
emitFunc :: (Serialize ev, Typeable res) => EventMap -> TypeString -> ev -> IO res
emitEvent' :: (Serialize ev, Typeable res) => TypeString -> ev -> IO res
emitEvent :: (Serialize ev, Typeable res) => ev -> IO res
setNewEventMap :: EventMap -> IO ()
data EventItem = EventItem {
eventContext :: TxContext
eventData :: Dynamic
}
eventStreamRef :: MVar (Chan EventItem)
initEventStream :: IO ()
pushEventItem :: Serialize ev => TxContext -> ev -> IO ()
getEventStream :: IO (IO EventItem)
createEventMap :: (Methods st, Component st) => MVar TxControl -> Proxy st -> IO EventMap
extraEvents :: Serialize st => TxRun st -> EventMap
allStateTypes :: (Methods a, Component a) => Proxy a -> [TypeString]
componentVersions :: (Methods a, Component a) => Proxy a -> Map String [ByteString]
componentIO :: (Methods a, Component a) => Proxy a -> [IO ()]
createNewTxRun :: IO (TxRun st)
setNewStateType :: String -> String
getStateType :: String -> String
setNewState :: TypeString -> ByteString -> IO ()
setNewState' :: EventMap -> TypeString -> ByteString -> IO ()
getState :: TypeString -> IO ByteString
data SetNewState st = SetNewState ByteString
data GetState st = GetState
update :: (MonadIO m, UpdateEvent ev res) => ev -> m res
query :: (MonadIO m, QueryEvent ev res) => ev -> m res
quickQuery' :: Serialize st => TxRun st -> HR st -> IO ()
type Runner ev res = IO (IO ev, res -> IO ())
type EH i o = i -> IO o
data Event = forall ev . Serialize ev => Event ev
data IHR st = forall ev . Serialize ev => IHR TxContext ev (RunHandler st ev)
data HR st = forall ev . Serialize ev => HR ev (RunHandler st ev)
type RunHandler st ev = TxContext -> st -> IO (Maybe st, IO ())
data Res a
= Ok a
| Error ExceptionT
type EventQueue st = TChan (HR st)
type ProcessQueue st = TChan (IHR st)
data TxRun st = TxRun {
txProcessQueue :: !(ProcessQueue st)
txLastTxContext :: !(TVar TxContext)
}
type EvLoaders' st = Map String (ProcessQueue st -> ByteString -> IO (TxId, ByteString))
type EvLoaders = Map String (ByteString -> IO (TxId, ByteString))
setEvLoadersQueue :: ProcessQueue st -> EvLoaders' st -> EvLoaders
runObjectEvent :: Object -> IO Object
runObjectEventFunc :: Object -> EventMap -> IO Object
runColdEvent :: TxContext -> Object -> IO Object
runColdEventFunc :: TxContext -> Object -> EventMap -> IO Object
lookupEventHandler :: TypeString -> EventMap -> IO EventHandler
eventTString :: Serialize ev => ev -> TypeString
handleEvent :: (st -> Env -> Ev m res -> STM intermediate) -> (st -> intermediate -> IO (Maybe st, res)) -> (Either ExceptionT res -> IO ()) -> Ev m res -> RunHandler st ev
handleQuery :: (Either ExceptionT res -> IO ()) -> Query st res -> RunHandler st ev
handleUpdate :: (Either ExceptionT res -> IO ()) -> Update st res -> RunHandler st ev
checkDiff :: a -> a -> IO (Maybe a)
getEpochMilli :: IO EpochMilli
newTxContext :: IO TxContext
addTxId :: TxRun st -> TxContext -> STM TxContext
globalRandomGen :: MVar StdGen
data TxControl = TxControl {
ctlSaver :: Saver
ctlEventSaver :: MVar (WriterStream EventLogEntry)
ctlAllComponents :: [String]
ctlComponentVersions :: Map String [ByteString]
ctlChildren :: [(ThreadId, MVar ())]
ctlPrefixLock :: Maybe PrefixLock
ctlCreateCheckpoint :: IO ()
}
data EventLogEntry = EventLogEntry TxContext Object
runTxLoop :: MVar (WriterStream EventLogEntry) -> ProcessQueue st -> st -> IO ()
Documentation
type ExceptionT = SomeExceptionSource
logMT :: Priority -> String -> IO ()Source
getTime :: Integral epochTime => AnyEv epochTimeSource
getEventClockTime :: AnyEv ClockTimeSource
getEventId :: Integral txId => AnyEv txIdSource
data GetCheckpointState Source
Constructors
GetCheckpointState
show/hide Instances
newtype SetCheckpointState Source
Constructors
SetCheckpointState ByteString
show/hide Instances
type TypeString = StringSource
data EventHandler whereSource
Constructors
UpdateHandler :: UpdateEvent ev res => (TxContext -> ev -> IO res) -> (ev -> IO res) -> (Object -> ev) -> EventHandler
QueryHandler :: QueryEvent ev res => (ev -> IO res) -> (Object -> ev) -> EventHandler
type EventMap = Map TypeString EventHandlerSource
data EmitInternal Source
Constructors
EmitInternal EventMap
emitRef :: IORef EmitInternalSource
emitFunc :: (Serialize ev, Typeable res) => EventMap -> TypeString -> ev -> IO resSource
emitEvent' :: (Serialize ev, Typeable res) => TypeString -> ev -> IO resSource
emitEvent :: (Serialize ev, Typeable res) => ev -> IO resSource
setNewEventMap :: EventMap -> IO ()Source
data EventItem Source
Constructors
EventItem
eventContext :: TxContext
eventData :: Dynamic
eventStreamRef :: MVar (Chan EventItem)Source
initEventStream :: IO ()Source
pushEventItem :: Serialize ev => TxContext -> ev -> IO ()Source
getEventStream :: IO (IO EventItem)Source
createEventMap :: (Methods st, Component st) => MVar TxControl -> Proxy st -> IO EventMapSource
extraEvents :: Serialize st => TxRun st -> EventMapSource
allStateTypes :: (Methods a, Component a) => Proxy a -> [TypeString]Source
componentVersions :: (Methods a, Component a) => Proxy a -> Map String [ByteString]Source
componentIO :: (Methods a, Component a) => Proxy a -> [IO ()]Source
createNewTxRun :: IO (TxRun st)Source
setNewStateType :: String -> StringSource
getStateType :: String -> StringSource
setNewState :: TypeString -> ByteString -> IO ()Source
setNewState' :: EventMap -> TypeString -> ByteString -> IO ()Source
getState :: TypeString -> IO ByteStringSource
data SetNewState st Source
Constructors
SetNewState ByteString
show/hide Instances
data GetState st Source
Constructors
GetState
show/hide Instances
update :: (MonadIO m, UpdateEvent ev res) => ev -> m resSource
Schedule an update and wait for it to complete. When this function returns, you're guaranteed the update will be persistent.
query :: (MonadIO m, QueryEvent ev res) => ev -> m resSource
Emit a state query and wait for the result.
quickQuery' :: Serialize st => TxRun st -> HR st -> IO ()Source
type Runner ev res = IO (IO ev, res -> IO ())Source
type EH i o = i -> IO oSource
data Event Source
Constructors
forall ev . Serialize ev => Event ev
data IHR st Source
Constructors
forall ev . Serialize ev => IHR TxContext ev (RunHandler st ev)
data HR st Source
Constructors
forall ev . Serialize ev => HR ev (RunHandler st ev)
type RunHandler st ev = TxContext -> st -> IO (Maybe st, IO ())Source
data Res a Source
Constructors
Ok a
Error ExceptionT
type EventQueue st = TChan (HR st)Source
type ProcessQueue st = TChan (IHR st)Source
data TxRun st Source
Constructors
TxRun
txProcessQueue :: !(ProcessQueue st)
txLastTxContext :: !(TVar TxContext)
type EvLoaders' st = Map String (ProcessQueue st -> ByteString -> IO (TxId, ByteString))Source
type EvLoaders = Map String (ByteString -> IO (TxId, ByteString))Source
setEvLoadersQueue :: ProcessQueue st -> EvLoaders' st -> EvLoadersSource
runObjectEvent :: Object -> IO ObjectSource
runObjectEventFunc :: Object -> EventMap -> IO ObjectSource
runColdEvent :: TxContext -> Object -> IO ObjectSource
runColdEventFunc :: TxContext -> Object -> EventMap -> IO ObjectSource
lookupEventHandler :: TypeString -> EventMap -> IO EventHandlerSource
eventTString :: Serialize ev => ev -> TypeStringSource
handleEvent :: (st -> Env -> Ev m res -> STM intermediate) -> (st -> intermediate -> IO (Maybe st, res)) -> (Either ExceptionT res -> IO ()) -> Ev m res -> RunHandler st evSource
handleQuery :: (Either ExceptionT res -> IO ()) -> Query st res -> RunHandler st evSource
handleUpdate :: (Either ExceptionT res -> IO ()) -> Update st res -> RunHandler st evSource
checkDiff :: a -> a -> IO (Maybe a)Source
getEpochMilli :: IO EpochMilliSource
newTxContext :: IO TxContextSource
addTxId :: TxRun st -> TxContext -> STM TxContextSource
globalRandomGen :: MVar StdGenSource
data TxControl Source
Constructors
TxControl
ctlSaver :: SaverSaver given by the user.
ctlEventSaver :: MVar (WriterStream EventLogEntry)
ctlAllComponents :: [String]Types of each component used.
ctlComponentVersions :: Map String [ByteString]Map listing all versions of a component
ctlChildren :: [(ThreadId, MVar ())]
ctlPrefixLock :: Maybe PrefixLockStores exclusive prefix lock (implemented in filesystem)
ctlCreateCheckpoint :: IO ()
data EventLogEntry Source
Constructors
EventLogEntry TxContext Object
show/hide Instances
runTxLoop :: MVar (WriterStream EventLogEntry) -> ProcessQueue st -> st -> IO ()Source
Produced by Haddock version 2.6.1