module FoundationDB.Internal.Database
( FoundationDBOptions (..),
defaultOptions,
Database (..),
apiVersionInUse,
)
where
import qualified FoundationDB.Internal.Bindings as FDB
import FoundationDB.Options.DatabaseOption (DatabaseOption (..))
import FoundationDB.Options.NetworkOption (NetworkOption (..))
data FoundationDBOptions = FoundationDBOptions
{
FoundationDBOptions -> Int
apiVersion :: Int,
FoundationDBOptions -> Maybe FilePath
clusterFile :: Maybe FilePath,
FoundationDBOptions -> [NetworkOption]
networkOptions :: [NetworkOption],
FoundationDBOptions -> [DatabaseOption]
databaseOptions :: [DatabaseOption]
}
deriving (Int -> FoundationDBOptions -> ShowS
[FoundationDBOptions] -> ShowS
FoundationDBOptions -> FilePath
(Int -> FoundationDBOptions -> ShowS)
-> (FoundationDBOptions -> FilePath)
-> ([FoundationDBOptions] -> ShowS)
-> Show FoundationDBOptions
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [FoundationDBOptions] -> ShowS
$cshowList :: [FoundationDBOptions] -> ShowS
show :: FoundationDBOptions -> FilePath
$cshow :: FoundationDBOptions -> FilePath
showsPrec :: Int -> FoundationDBOptions -> ShowS
$cshowsPrec :: Int -> FoundationDBOptions -> ShowS
Show, FoundationDBOptions -> FoundationDBOptions -> Bool
(FoundationDBOptions -> FoundationDBOptions -> Bool)
-> (FoundationDBOptions -> FoundationDBOptions -> Bool)
-> Eq FoundationDBOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FoundationDBOptions -> FoundationDBOptions -> Bool
$c/= :: FoundationDBOptions -> FoundationDBOptions -> Bool
== :: FoundationDBOptions -> FoundationDBOptions -> Bool
$c== :: FoundationDBOptions -> FoundationDBOptions -> Bool
Eq, Eq FoundationDBOptions
Eq FoundationDBOptions
-> (FoundationDBOptions -> FoundationDBOptions -> Ordering)
-> (FoundationDBOptions -> FoundationDBOptions -> Bool)
-> (FoundationDBOptions -> FoundationDBOptions -> Bool)
-> (FoundationDBOptions -> FoundationDBOptions -> Bool)
-> (FoundationDBOptions -> FoundationDBOptions -> Bool)
-> (FoundationDBOptions
-> FoundationDBOptions -> FoundationDBOptions)
-> (FoundationDBOptions
-> FoundationDBOptions -> FoundationDBOptions)
-> Ord FoundationDBOptions
FoundationDBOptions -> FoundationDBOptions -> Bool
FoundationDBOptions -> FoundationDBOptions -> Ordering
FoundationDBOptions -> FoundationDBOptions -> FoundationDBOptions
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: FoundationDBOptions -> FoundationDBOptions -> FoundationDBOptions
$cmin :: FoundationDBOptions -> FoundationDBOptions -> FoundationDBOptions
max :: FoundationDBOptions -> FoundationDBOptions -> FoundationDBOptions
$cmax :: FoundationDBOptions -> FoundationDBOptions -> FoundationDBOptions
>= :: FoundationDBOptions -> FoundationDBOptions -> Bool
$c>= :: FoundationDBOptions -> FoundationDBOptions -> Bool
> :: FoundationDBOptions -> FoundationDBOptions -> Bool
$c> :: FoundationDBOptions -> FoundationDBOptions -> Bool
<= :: FoundationDBOptions -> FoundationDBOptions -> Bool
$c<= :: FoundationDBOptions -> FoundationDBOptions -> Bool
< :: FoundationDBOptions -> FoundationDBOptions -> Bool
$c< :: FoundationDBOptions -> FoundationDBOptions -> Bool
compare :: FoundationDBOptions -> FoundationDBOptions -> Ordering
$ccompare :: FoundationDBOptions -> FoundationDBOptions -> Ordering
$cp1Ord :: Eq FoundationDBOptions
Ord)
defaultOptions :: FoundationDBOptions
defaultOptions :: FoundationDBOptions
defaultOptions = Int
-> Maybe FilePath
-> [NetworkOption]
-> [DatabaseOption]
-> FoundationDBOptions
FoundationDBOptions Int
FDB.currentAPIVersion Maybe FilePath
forall a. Maybe a
Nothing [] []
data Database = Database
{ Database -> DatabasePtr
databasePtr :: FDB.DatabasePtr,
Database -> FoundationDBOptions
databaseFoundationDBOptions :: FoundationDBOptions
}
deriving (Int -> Database -> ShowS
[Database] -> ShowS
Database -> FilePath
(Int -> Database -> ShowS)
-> (Database -> FilePath) -> ([Database] -> ShowS) -> Show Database
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [Database] -> ShowS
$cshowList :: [Database] -> ShowS
show :: Database -> FilePath
$cshow :: Database -> FilePath
showsPrec :: Int -> Database -> ShowS
$cshowsPrec :: Int -> Database -> ShowS
Show, Database -> Database -> Bool
(Database -> Database -> Bool)
-> (Database -> Database -> Bool) -> Eq Database
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Database -> Database -> Bool
$c/= :: Database -> Database -> Bool
== :: Database -> Database -> Bool
$c== :: Database -> Database -> Bool
Eq)
apiVersionInUse :: Database -> Int
apiVersionInUse :: Database -> Int
apiVersionInUse = FoundationDBOptions -> Int
apiVersion (FoundationDBOptions -> Int)
-> (Database -> FoundationDBOptions) -> Database -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Database -> FoundationDBOptions
databaseFoundationDBOptions