avers- empty

Safe HaskellNone



This module abstracts the storage engine and provides functions to manipulate objects stored in it.



exists :: ObjId -> Avers Bool Source #

True if the object exists.

lookupObject :: ObjId -> Avers Object Source #

Lookup an Object by its ObjId. Throws ObjectNotFound if the object doesn't exist.

createObject :: ToJSON a => ObjectType a -> ObjId -> a -> Avers ObjId Source #

Create a new object of the given type. An initial snapshot (RevId 0) is created from the supplied content.

createObject' :: ToJSON a => ObjId -> UTCTime -> ObjectType a -> ObjId -> a -> Avers () Source #

A more low-level version of createObject, for use when you want to generate your own ObjId or create objects at a specific time.

deleteObject :: ObjId -> Avers () Source #

Mark the object as deleted.

pruneObject :: ObjId -> Avers () Source #

Prune the object from the database. This is only allowed if the object is marked as deleted. Note that this is a very dangerous operation, it can not be undone.

TODO: Prune related Release and Authoriation objects.

createCheckpoint :: ObjectId -> ObjId -> Avers RevId Source #

Create a checkpoint for for the given object. All patches (and of course snapshots) before the checkpoint can be dropped. Use vacuumObject to do that.

vacuumObject :: ObjectId -> Avers () Source #

Drop all patches and snapshots before the most recent checkpoint. This effectively drops the object's history, and frees space in the database.

objectContent :: FromJSON a => ObjectId -> Avers a Source #

Fetch the content of the object and try to parse it.

This function will fail with a ParseError if the content can not be decoded into the desired type.

lookupLatestSnapshot :: ObjectId -> Avers Snapshot Source #

Get the snapshot of the newest revision of the given object.

latestSnapshotBetween :: ObjectId -> Int -> Int -> Avers Snapshot Source #

Lookup the latest snapshot within the given range. The bounds are inclusive.

newestSnapshot :: ObjectId -> Avers Snapshot Source #

Get the newest snapshot which is stored in the database. The object may be at a higher revision if the later snapshots are missing from the database.

This is an internal function. If you want the latest snapshot, you should use lookupLatestSnapshot.

lookupSnapshot :: ObjectId -> RevId -> Avers Snapshot Source #

Lookup the snapshot at a particular revision.

verifySecret :: SecretId -> Text -> Avers () Source #

Verify the value against the secret. If that fails, then this function throws an error.

This function automatically updates the secret in the database if the scrypt params have changed.

saveSecretValue :: SecretId -> EncryptedPass -> Avers () Source #

Internal function which actually saves a secret in the database.

lookupObjectType :: Text -> Avers SomeObjectType Source #

Lookup an object type which is registered in the Avers monad.

applyObjectUpdates Source #


:: ObjectId

The object which you want to update

-> RevId

The RevId against which the operations were created

-> ObjId


-> [Operation]

The operations to apply

-> Bool

True if validation should be skipped

-> Avers ([Patch], Int, [Patch]) 

createRelease :: ObjId -> RevId -> Avers () Source #

Create a new release of the given revision. If the object doesn't exist, it will fail with ObjectNotFound.

indexF :: Exp Object -> Exp (Array Datum) Source #

Bootstrap the Avers handle: Create necessary tables, indexes, views etc. This operation is idempotent.

streamPatches :: Pool Handle -> TChan Change -> IO () Source #

Stream new patches from the database into the channel.

changeChannel :: Handle -> IO (TChan Change) Source #

Return a TChan to which all changes in the system are streamed. Make sure to continuously drain items from the TChan, otherwise they will accumulate in memory and you will run OOM eventually.

Do not write into the channel!