on f843252 help sign in
38 lines 1.4 kB history raw
1--types shared across server and client modules
2module ProjectM36.Server.Types where
3import StmContainers.Set as StmSet
4import ProjectM36.Base
5import Data.Hashable
6import ProjectM36.Sessions
7import Control.Concurrent.STM
8import ProjectM36.ScriptSession
9import ProjectM36.FileLock
10import Control.Concurrent.MVar
11import ProjectM36.TransactionGraph.Persist
12import Network.RPC.Curryer.Server as RPC
13import Network.Socket
15-- | The 'Connection' represents either local or remote access to a database. All operations flow through the connection.
16type ClientNodes = StmSet.Set ClientInfo
18type DatabaseName = String
20-- internal structure specific to in-process connections
21data InProcessConnectionConf = InProcessConnectionConf {
22 ipPersistenceStrategy :: PersistenceStrategy,
23 ipClientNodes :: ClientNodes,
24 ipSessions :: Sessions,
25 ipTransactionGraph :: TVar TransactionGraph,
26 ipScriptSession :: Maybe ScriptSession,
27 ipLocks :: Maybe (LockFile, MVar LockFileHash) -- nothing when NoPersistence
28 }
30-- clients may connect associate one socket with one database
31data ClientInfo = ClientInfo { clientDatabaseName :: DatabaseName,
32 clientSocket :: RPC.Locking Socket }
34instance Eq ClientInfo where
35 a == b = RPC.lockless (clientSocket a) == RPC.lockless (clientSocket b)
37instance Hashable ClientInfo where
38 hashWithSalt salt ci = hashWithSalt salt (show (RPC.lockless (clientSocket ci)))