avers-0.0.15: empty

Safe HaskellNone
LanguageHaskell2010

Avers.Types

Synopsis

Documentation

class Pk a where Source

Pk - Types which can be converted to a database primary key.

Methods

toPk :: a -> Text Source

rootPath :: Path Source

This path refers to the root of an object. It is only used in Set operations.

rootObjId :: ObjId Source

The root object id is used for object created internally or when there is no applicable creator.

zeroRevId :: RevId Source

The RevId which is used for the initial snapshot.

data ObjectId Source

ObjectId

Constructors

BaseObjectId !ObjId

The base object whose snapshots contain the actual content.

ReleaseObjectId !ObjId !RevId

An object describing a particualar release of the base object.

AuthorizationObjectId !ObjId

Object which contains authorization rules.

data Operation Source

The operations that can be applied to JSON values.

Constructors

Set

Set is applied to Objects. It is used for adding, updating and deleting properties from the object.

Fields

opPath :: !Path
 
opValue :: !(Maybe Value)
 
Splice

Splice is used to manipulate Arrays. It can remove and insert multiple elements in a single operation.

Fields

opPath :: !Path
 
opIndex :: !Int
 
opRemove :: !Int
 
opInsert :: ![Value]
 

initialSnapshot :: ObjectId -> Snapshot Source

The initial snapshot on top of which all future patches are applied.

data Release Source

Release

Constructors

Release 

(deriveJSONOptions "release") ''Release)

data Secret Source

Secret

A Secret is a password (encrypted with scrypt) that is attached to a SecretId (for example the ObjId of an account).

It is up to you to ensure that SecretIds are unique. If you use ObjIds then they by definition are.

Constructors

Secret 

data Session Source

The session record that is stored in the database.

A session is a unique identifier attached to a particular object. It contains the creation date and when it was last accessed. If you need to store additional data for a session, we recommend to use cookies.

data ObjectType a Source

An ObjectType describes a particular type of object that is managed by Avers.

Constructors

ObjectType 

Fields

otType :: !Text

The value of the type field of the Object.

otId :: Avers ObjId

Action which generates a new id. This is so that object types can have different strategies how to generate ids.

otViews :: [SomeView a]
 

data Config Source

Configuration of the Avers monad.

Constructors

Config 

Fields

databaseURI :: !URI

URI which describes the connection details to the RethinkDB database. The URI *MUST* include at least the hostname (uriRegName) and database name (uriPath without the leading slash). The port (uriPort) and credentials (uriUserInfo) *MAY* be left empty. in that case the default port will be used.

putBlob :: BlobId -> Text -> ByteString -> IO (Either AversError ())

Function which saves the given blob in the blob store. This can be the local filesystem or an external service such as Amazon S3.

objectTypes :: ![SomeObjectType]

All the object types which Avers knows about.

emitMeasurement :: Measurement -> Double -> IO ()

This is called when the internal instrumentation code creates a measurement.

data Change Source

A change in the system, for example a new object, patch, release, blob etc.

Constructors

CPatch !Patch

A new patch was created.

data Handle Source

Constructors

Handle 

Fields

hConfig :: !Config

A reference to the config, just in case we need it.

hDatabaseHandlePool :: !(Pool Handle)

A pool of handles which are used to access the database.

hRecentRevisionCache :: !(TVar (Map ObjectId RevId))

Map from ObjectId to a recent RevId. It may be the latest or a few revisions behind.

hChanges :: !(TChan Change)

Changes in the system (new patches, objects, releases etc), even those created through other handles, are streamed into this channel. If you want to be informed of those changes, duplicate the channel and read from the copy.

class Monad m => MonadAvers m where Source

Methods

liftAvers :: Avers a -> m a Source

data View obj a Source

Constructors

View 

Fields

viewName :: Text

The table name is derived from the view name. Therefore it should be unique amongst all views.

viewParser :: Datum -> Either AversError a

Function which parses objects stored in this view.

viewObjectTransformer :: obj -> Avers (Maybe a)

Function which transforms an Avers Object into a type stored in the view.

viewIndices :: [SomeIndex]

Secondary indices defined on the view.

data SomeView obj where Source

Constructors

SomeView :: (ToDatum a, FromDatum a, FromJSON obj, ToJSON a) => View obj a -> SomeView obj