Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module abstracts the storage engine and provides functions to manipulate objects stored in it.
- requireResult :: AversError -> Maybe a -> Avers a
- exists :: ObjId -> Avers Bool
- lookupObject :: ObjId -> Avers Object
- createObject :: ToJSON a => ObjectType a -> ObjId -> a -> Avers ObjId
- createObject' :: ToJSON a => ObjId -> UTCTime -> ObjectType a -> ObjId -> a -> Avers ()
- deleteObject :: ObjId -> Avers ()
- pruneObject :: ObjId -> Avers ()
- createCheckpoint :: ObjectId -> ObjId -> Avers RevId
- isCheckpointPatch :: Patch -> Bool
- latestCheckpointPatch :: ObjectId -> Avers (Maybe Patch)
- vacuumObject :: ObjectId -> Avers ()
- objectContent :: FromJSON a => ObjectId -> Avers a
- lookupLatestSnapshot :: ObjectId -> Avers Snapshot
- applyPatchToSnapshot :: Snapshot -> Patch -> Avers Snapshot
- applyPatches :: Snapshot -> [Patch] -> Avers Snapshot
- lookupRecentRevision :: ObjectId -> Avers (Maybe RevId)
- updateRecentRevision :: ObjectId -> RevId -> Avers ()
- latestSnapshotBetween :: ObjectId -> Int -> Int -> Avers Snapshot
- newestSnapshot :: ObjectId -> Avers Snapshot
- lookupSnapshot :: ObjectId -> RevId -> Avers Snapshot
- savePatch :: Patch -> Avers ()
- saveSnapshot :: Snapshot -> Avers ()
- updateSecret :: SecretId -> Text -> Avers ()
- verifySecret :: SecretId -> Text -> Avers ()
- saveSecretValue :: SecretId -> EncryptedPass -> Avers ()
- objectPatches :: ObjectId -> Avers [Patch]
- patchesAfterRevision :: ObjectId -> RevId -> Avers [Patch]
- lookupPatch :: ObjectId -> RevId -> Avers Patch
- lookupObjectType :: Text -> Avers SomeObjectType
- applyObjectUpdates :: ObjectId -> RevId -> ObjId -> [Operation] -> Bool -> Avers ([Patch], Int, [Patch])
- data PatchState a = PatchState {}
- type AversPatch a b = StateT (PatchState a) Avers b
- patchHandler :: FromJSON a => Bool -> AversPatch a Snapshot
- existsBlob :: BlobId -> Avers Bool
- lookupBlob :: BlobId -> Avers Blob
- insertBlob :: Blob -> Avers ()
- saveBlobContent :: Blob -> ByteString -> Avers ()
- saveSession :: Session -> Avers ()
- lookupSession :: SessionId -> Avers Session
- dropSession :: SessionId -> Avers ()
- newId :: Int -> IO Text
- validateObject :: Text -> Value -> Avers ()
- validateWithType :: FromJSON a => ObjectType a -> Value -> Avers ()
- lookupRelease :: ObjId -> RevId -> Avers Release
- createRelease :: ObjId -> RevId -> Avers ()
- lookupLatestRelease :: ObjId -> Avers (Maybe RevId)
- createBlob :: ByteString -> Text -> Avers Blob
- objectsOfType :: ObjectType a -> Avers (Vector ObjId)
- allObjectsOfType :: ObjectType a -> Avers (Vector ObjId)
- isNotDeleted :: Exp Object -> Exp Bool
- mapId :: Exp Object -> Exp Text
- indexF :: Exp Object -> Exp (Array Datum)
- bootstrap :: Avers ()
- createTable :: Text -> [SomeIndex] -> Avers ()
- streamPatches :: Pool Handle -> TChan Change -> IO ()
- changeChannel :: Handle -> IO (TChan Change)
Documentation
requireResult :: AversError -> Maybe a -> Avers a Source #
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.
isCheckpointPatch :: Patch -> Bool Source #
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.
saveSnapshot :: Snapshot -> Avers () Source #
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.
data PatchState a Source #
PatchState | |
|
type AversPatch a b = StateT (PatchState a) Avers b Source #
patchHandler :: FromJSON a => Bool -> AversPatch a Snapshot Source #
insertBlob :: Blob -> Avers () Source #
saveBlobContent :: Blob -> ByteString -> Avers () Source #
saveSession :: Session -> Avers () Source #
dropSession :: SessionId -> Avers () Source #
validateWithType :: FromJSON a => ObjectType a -> Value -> Avers () Source #
createRelease :: ObjId -> RevId -> Avers () Source #
Create a new release of the given revision. If the object doesn't exist,
it will fail with ObjectNotFound
.
createBlob :: ByteString -> Text -> Avers Blob Source #
objectsOfType :: ObjectType a -> Avers (Vector ObjId) Source #
allObjectsOfType :: ObjectType a -> Avers (Vector ObjId) Source #
indexF :: Exp Object -> Exp (Array Datum) Source #
Bootstrap the Avers handle: Create necessary tables, indexes, views etc. This operation is idempotent.