icepeak-0.7.2.0: A fast JSON document store with push notification support.

Safe HaskellNone
LanguageHaskell2010

Core

Synopsis

Documentation

data Command Source #

Defines the kinds of commands that are handled by the event loop of the Core.

Constructors

Sync

The Sync command causes the core to write the JSON value to disk.

Modify Modification (Maybe (MVar ()))

The Modify command applies a modification (writing or deleting) to the JSON value. The optional MVar is used to signal that the command has been processed by the core.

Stop

The Stop command causes the event loop of the Core to exit.

Instances
Eq Command Source # 
Instance details

Defined in Core

Methods

(==) :: Command -> Command -> Bool #

(/=) :: Command -> Command -> Bool #

data Updated Source #

Constructors

Updated Path Value 
Instances
Eq Updated Source # 
Instance details

Defined in Core

Methods

(==) :: Updated -> Updated -> Bool #

(/=) :: Updated -> Updated -> Bool #

Show Updated Source # 
Instance details

Defined in Core

enqueueCommand :: Command -> Core -> IO () Source #

Enqueue a command. Blocks if the queue is full. This is used by the sync timer to make sure the sync commands are actually enqueued. In general, whenever it is critical that a command is executed eventually (when reaching the front of the queue), this function should be used.

tryEnqueueCommand :: Command -> Core -> IO EnqueueResult Source #

Try to enqueue a command. It succeeds if the queue is not full, otherwise, nothing is changed. This should be used for non-critical commands that can also be retried later.

withCoreMetrics :: MonadIO m => Core -> (IcepeakMetrics -> IO ()) -> m () Source #

lookup :: Eq a => a -> [(a, b)] -> Maybe b #

lookup key assocs looks up a key in an association list.

newCore :: Config -> Logger -> Maybe IcepeakMetrics -> IO (Either String Core) Source #

Try to initialize the core. This loads the database and sets up the internal data structures.

runCommandLoop :: Core -> IO () Source #

Drain the command queue and execute them. Changes are published to all subscribers. This function returns when executing the Stop command from the queue.

runSyncTimer :: Core -> IO () Source #

Periodically send a Sync command to the Core if enabled in the core configuration.