hydra-node-0.16.0: The Hydra node
Safe HaskellSafe-Inferred
LanguageGHC2021

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

Documentation

data Persistence a m Source #

Handle to save and load files to/from disk using JSON encoding.

Constructors

Persistence 

Fields

  • save :: ToJSON a => a -> m ()
     
  • load :: FromJSON a => m (Maybe a)
     

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 

Fields

  • append :: ToJSON a => a -> m ()
     
  • loadAll :: FromJSON a => m [a]
     

createPersistenceIncremental :: forall a m. (MonadIO m, MonadThrow m, MonadSTM m, MonadThread m, MonadThrow (STM m)) => 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:PersistenceIncrementaling through the handle. If another thread attempts to $sel:loadAll:PersistenceIncremental after this point, an IncorrectAccessException will be raised.