Database.MongoDB.Connection
Contents
Description
A pool of TCP connections to a single server or a replica set of servers.
- data Host = Host HostName PortID
- data PortID
- host :: HostName -> Host
- showHostPort :: Host -> String
- readHostPort :: String -> Host
- readHostPortM :: Monad m => String -> m Host
- data ReplicaSet = ReplicaSet {}
- type Name = UString
- data MasterOrSlaveOk
- class Server t where
- connHost :: ConnPool Host -> Host
- replicaSet :: MonadIO' m => ConnPool ReplicaSet -> m ReplicaSet
Host
data PortID
Constructors
Service String | |
PortNumber PortNumber | |
UnixSocket String |
showHostPort :: Host -> StringSource
Display host as "host:port"
readHostPort :: String -> HostSource
Read string "hostname:port" as Host hostname port
or "hostname" as host hostname
(default port). Error if string does not match either syntax.
readHostPortM :: Monad m => String -> m HostSource
Read string "hostname:port" as Host hosthame port
or "hostname" as host hostname
(default port). Fail if string does not match either syntax.
ReplicaSet
data ReplicaSet Source
Replica set of hosts identified by set name. At least one of the seed hosts must be an active member of the set. However, this list is not used to identify the set, just the set name.
Constructors
ReplicaSet | |
Instances
MasterOrSlaveOk
data MasterOrSlaveOk Source
Instances
Connection Pool
A Server is a single server (Host
) or a replica set of servers (ReplicaSet
)
Associated Types
A pool of TCP connections (Pipe
s) to a host or a replica set of hosts
Methods
newConnPool :: MonadIO' m => Int -> t -> m (ConnPool t)Source
Create a ConnectionPool to a host or a replica set of hosts. Actual TCP connection is not attempted until getPipe
request, so no IOError can be raised here. Up to N TCP connections will be established to each host.
getPipe :: MasterOrSlaveOk -> ConnPool t -> ErrorT IOError IO PipeSource
Return a TCP connection (Pipe) to the master or a slave in the server. Master must connect to the master, SlaveOk may connect to a slave or master. To spread the load, SlaveOk requests are distributed amongst all hosts in the server. Throw IOError if failed to connect to right type of host (Master/SlaveOk).
killPipes :: ConnPool t -> IO ()Source
Kill all open pipes (TCP Connections). Will cause any users of them to fail. Alternatively you can let them die on their own when they are garbage collected.
Instances
replicaSet :: MonadIO' m => ConnPool ReplicaSet -> m ReplicaSetSource
Return replicas set name with current members as seed list