Safe Haskell | None |
---|---|
Language | Haskell2010 |
Versionstamps. For a great overview, see https://forums.foundationdb.org/t/implementing-versionstamps-in-bindings/250
Synopsis
- data Versionstamp (a :: VersionstampCompleteness) where
- data VersionstampCompleteness
- data TransactionVersionstamp = TransactionVersionstamp Word64 Word16
- encodeVersionstamp :: Versionstamp a -> ByteString
- encodeTransactionVersionstamp :: TransactionVersionstamp -> ByteString
- decodeVersionstamp :: ByteString -> Maybe (Versionstamp 'Complete)
- decodeTransactionVersionstamp :: ByteString -> Maybe TransactionVersionstamp
- transactionVersion :: TransactionVersionstamp -> Word64
- transactionBatchOrder :: TransactionVersionstamp -> Word16
- userVersion :: Versionstamp a -> Word16
Documentation
data Versionstamp (a :: VersionstampCompleteness) where Source #
Represents a version stamp. Version stamps consist of * An 8-byte transaction version * A 2-byte transaction batch order * A 2-byte user version
The first ten bytes are assigned by FoundationDB to each transaction in such a way that each transaction is numbered in a serializable order.
The last two bytes can be used by the user to further distinguish between multiple entities or keys that were committed in one transaction.
CompleteVersionstamp :: TransactionVersionstamp -> Word16 -> Versionstamp 'Complete | A complete version stamp, consisting of |
IncompleteVersionstamp :: Word16 -> Versionstamp 'Incomplete | A version stamp that has not yet been associated with a completed transaction. Such a version stamp does not yet have an associated transaction version and transaction batch order, but does have a user version. |
Instances
data VersionstampCompleteness Source #
Represents whether a versionstamp is complete (has been written to FDB and thus contains a full version integer) or incomplete (contains a user-provided version, but has not yet been committed to FDB).
data TransactionVersionstamp Source #
A TransactionVersionstamp
consists of a monotonically-increasing
8-byte transaction version and a 2-byte transaction batch order. Each
committed transaction has an associated TransactionVersionstamp
.
Instances
encodeVersionstamp :: Versionstamp a -> ByteString Source #
Encodes a versionstamp into a bytestring. You probably don't need this; see the facilities in FoundationDB.Layer.Tuple for a more flexible alternative.
decodeVersionstamp :: ByteString -> Maybe (Versionstamp 'Complete) Source #
Decode a versionstamp from a raw bytestring. You probably don't need this; see the facilities in FoundationDB.Layer.Tuple for a more flexible alternative.
transactionVersion :: TransactionVersionstamp -> Word64 Source #
Extracts the transaction version from the versionstamp. This is the database version at which the versionstamp was committed.
transactionBatchOrder :: TransactionVersionstamp -> Word16 Source #
Extracts the batch order from the versionstamp.
userVersion :: Versionstamp a -> Word16 Source #