@@ -23,7 +23,7 @@ Overview
23
23
This guide shows you how to use the {+php-library+} to monitor topology
24
24
events in a MongoDB instance, replica set, or sharded cluster. The
25
25
driver creates topology events, also known as Server Discovery and
26
- Monitoring (** SDAM** ) events, when there are any changes in the state of the
26
+ Monitoring (SDAM) events, when there are any changes in the state of the
27
27
MongoDB instance or cluster that you are connected to.
28
28
29
29
You might use information about topology events in your
@@ -34,14 +34,15 @@ Subscribe to Events
34
34
-------------------
35
35
36
36
You can access details about SDAM events by subscribing to them
37
- in your application. To subscribe to any event, create a class that
37
+ in your application. To subscribe to an event, create a class that
38
38
implements the ``MongoDB\Driver\Monitoring\SDAMSubscriber`` interface,
39
39
then use the ``MongoDB\Client::addSubscriber()`` method to register the
40
40
event subscriber with your ``MongoDB\Client`` instance.
41
41
42
- The following code creates the ``MySubscriber`` class that implements
43
- ``SDAMSubscriber`` to output a message when a ``ServerOpeningEvent`` is
44
- generated by the server:
42
+ The following code creates the ``MySubscriber`` class, which implements
43
+ the ``SDAMSubscriber`` interface. The class is defined with a method to
44
+ output a message when a ``ServerOpeningEvent`` is generated by the
45
+ server:
45
46
46
47
.. literalinclude:: /includes/monitoring/sdam.php
47
48
:start-after: start-mysubscriber
@@ -53,12 +54,12 @@ generated by the server:
53
54
.. note::
54
55
55
56
As shown in the preceding code, you must implement all of the methods
56
- of ``SDAMSubscriber``, even for events you are not subscribing to.
57
+ of the ``SDAMSubscriber`` interface , even for events you are not subscribing to.
57
58
You can implement these methods with empty bodies so that the library
58
59
does not generate any messages for these events.
59
60
60
- Then, the following code uses the ``addSubscriber()`` method to register
61
- ``MySubscriber`` with the client:
61
+ Then, use the ``addSubscriber()`` method to register ``MySubscriber``
62
+ with the client, as shown in the following code :
62
63
63
64
.. literalinclude:: /includes/monitoring/sdam.php
64
65
:start-after: start-add-sub
0 commit comments