Mongo.Monitor (mongodb-driver v0.7.3) View Source

Each server has a monitor process. The monitor process is created by the topology process.

If the network connection is working, then the monitor process reports this and the topology process starts the connection pool. Per server we get 1 + pool size connections to each server.

After waiting for heartbeat_frequency_ms milliseconds, the monitor process calls isMaster command and reports the result to the topology process.

The result of the isMaster command is mapped the ServerDescription structure and sent to the topology process, which updates it internal data structure.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Report the connection event, so the topology process can now create the connection pool.

Try to update the server description.

Time to update the topology. Calling isMaster and updating the server description

The :timeout call is the periodic call defined by the heartbeat frequency The ':update' call updates the server description for the topology process

Initialize the monitor process

Stop the monitor process.

In this case we stop the DBConnection.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

connected(connection, me, topology_pid)

View Source

Report the connection event, so the topology process can now create the connection pool.

Try to update the server description.

Time to update the topology. Calling isMaster and updating the server description

The :timeout call is the periodic call defined by the heartbeat frequency The ':update' call updates the server description for the topology process

Initialize the monitor process

Stop the monitor process.

We need to stop asynchronously because a Monitor can call the Topology which may try to stop the same Monitor that called it. Ending in a timeout.

Link to this function

terminate(reason, state)

View Source

In this case we stop the DBConnection.