Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Hydra.Persistence
Description
Handles to save/load files across the hydra-node. We use a simple JSON encoding and two modes of operation to store things: Full and Incremental.
Synopsis
- data PersistenceException
- data Persistence a m = Persistence {}
- createPersistence :: (MonadIO m, MonadThrow m) => FilePath -> m (Persistence a m)
- data PersistenceIncremental a m = PersistenceIncremental {}
- loadAll :: (FromJSON a, MonadUnliftIO m) => PersistenceIncremental a m -> m [a]
- createPersistenceIncremental :: forall a m. (MonadUnliftIO m, MonadThrow m, FromJSON a) => FilePath -> m (PersistenceIncremental a m)
Documentation
data PersistenceException Source #
Constructors
PersistenceException String | |
IncorrectAccessException String |
Instances
Exception PersistenceException Source # | |
Defined in Hydra.Persistence | |
Show PersistenceException Source # | |
Defined in Hydra.Persistence | |
Eq PersistenceException Source # | |
Defined in Hydra.Persistence Methods (==) :: PersistenceException -> PersistenceException -> Bool Source # (/=) :: PersistenceException -> PersistenceException -> Bool Source # |
data Persistence a m Source #
Handle to save and load files to/from disk using JSON encoding.
Constructors
Persistence | |
createPersistence :: (MonadIO m, MonadThrow m) => FilePath -> m (Persistence a m) Source #
Initialize persistence handle for given type a
at given file path.
data PersistenceIncremental a m Source #
Handle to save incrementally and load files to/from disk using JSON encoding.
Constructors
PersistenceIncremental | |
loadAll :: (FromJSON a, MonadUnliftIO m) => PersistenceIncremental a m -> m [a] Source #
Load all elements from persistence into a list. XXX: Deprecate this to avoid large memory usage.
createPersistenceIncremental :: forall a m. (MonadUnliftIO m, MonadThrow m, FromJSON a) => FilePath -> m (PersistenceIncremental a m) Source #
Initialize persistence handle for given type a
at given file path.
This instance of PersistenceIncremental
is "thread-safe" in the sense that
it prevents loading from a different thread once one starts $sel:append:PersistenceIncremental
ing
through the handle. If another thread attempts to $sel:source:PersistenceIncremental
(or loadAll
)
after this point, an IncorrectAccessException
will be raised.