mongoDB-0.9.3: MongoDB driver

Database.MongoDB.Connection

Contents

Description

A pool of TCP connections to a single server or a replica set of servers.

Synopsis

Pipe

type Pipe = Pipeline Message ResponseSource

Thread-safe TCP connection with pipelined requests

Host

host :: HostName -> HostSource

Host on default MongoDB port

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 

Fields

setName :: Name
 
seedHosts :: [Host]
 

MasterOrSlaveOk

data MasterOrSlaveOk Source

Constructors

Master

connect to master only

SlaveOk

connect to a slave, or master if no slave available

Connection Pool

class Service t whereSource

A Service is a single server (Host) or a replica set of servers (ReplicaSet)

Associated Types

data ConnPool t Source

A pool of TCP connections (Pipes) to a host or a replica set of hosts

Methods

newConnPool :: NetworkIO 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 -> IOE 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 get garbage collected.

replicaSet :: MonadIO' m => ConnPool ReplicaSet -> m ReplicaSetSource

Return replicas set name with current members as seed list