@@ -95,14 +95,29 @@ Command Event Subscriber Example
95
95
96
96
To subscribe to an SDAM event, create a class that implements the
97
97
``MongoDB\Driver\Monitoring\CommandSubscriber`` interface. In your
98
- class, define each of the following ``CommandSubscriber`` methods:
98
+ class, define each of the ``CommandSubscriber`` methods. The following
99
+ table describes these methods and the command events they receive notifications
100
+ for:
99
101
100
- - :php:`commandFailed() <mongodb-driver-monitoring-commandsubscriber.commandfailed>`: Called
101
- when a command does not succeed
102
- - :php:`commandStarted() <mongodb-driver-monitoring-commandsubscriber.commandstarted>`: Called
103
- when a command is sent to the server
104
- - :php:`commandSucceeded() <mongodb-driver-monitoring-commandsubscriber.commandsucceeded>`: Called
105
- when a command succeeds
102
+ .. list-table::
103
+ :header-rows: 1
104
+ :widths: 20 20 60
105
+
106
+ * - Method
107
+ - Command Event
108
+ - Description
109
+
110
+ * - :php:`commandFailed() <mongodb-driver-monitoring-commandsubscriber.commandfailed>`
111
+ - :php:`CommandFailedEvent <class.mongodb-driver-monitoring-commandfailedevent>`
112
+ - Called when a command does not succeed
113
+
114
+ * - :php:`commandStarted() <mongodb-driver-monitoring-commandsubscriber.commandstarted>`
115
+ - :php:`CommandStartedEvent <class.mongodb-driver-monitoring-commandstartedevent>`
116
+ - Called when a command is sent to the server
117
+
118
+ * - :php:`commandSucceeded() <mongodb-driver-monitoring-commandsubscriber.commandsucceeded>`
119
+ - :php:`CommandSucceededEvent <class.mongodb-driver-monitoring-commandsucceededevent>`
120
+ - Called when a command succeeds
106
121
107
122
The following code creates the ``MyCommandSubscriber`` class, which implements
108
123
the ``CommandSubscriber`` interface. The class defines each ``CommandSubscriber`` method
@@ -123,26 +138,53 @@ SDAM Event Subscriber Example
123
138
124
139
To subscribe to an SDAM event, create a class that implements the
125
140
``MongoDB\Driver\Monitoring\SDAMSubscriber`` interface. In your
126
- class, define each of the following ``SDAMSubscriber`` methods:
127
-
128
- - :php:`serverChanged() <mongodb-driver-monitoring-sdamsubscriber.serverchanged>`: Called
129
- when a server's description changes
130
- - :php:`serverClosed() <mongodb-driver-monitoring-sdamsubscriber.serverclosed>`: Called
131
- when a server is removed from the topology
132
- - :php:`serverHeartbeatFailed() <mongodb-driver-monitoring-sdamsubscriber.serverheartbeatfailed>`: Called
133
- when a server heartbeat is unsuccessful
134
- - :php:`serverHeartbeatStarted() <mongodb-driver-monitoring-sdamsubscriber.serverheartbeatstarted>`: Called
135
- when the server receives a heartbeat
136
- - :php:`serverHeartbeatSucceeded() <mongodb-driver-monitoring-sdamsubscriber.serverheartbeatsucceeded>`: Called
137
- when a server heartbeat succeeds
138
- - :php:`serverOpening() <mongodb-driver-monitoring-sdamsubscriber.serveropening>`: Called
139
- when a new server is added to the topology
140
- - :php:`topologyChanged() <mongodb-driver-monitoring-sdamsubscriber.topologychanged>`: Called
141
- when a new server is added to the topology
142
- - :php:`topologyClosed() <mongodb-driver-monitoring-sdamsubscriber.topologyclosed>`: Called
143
- when the topology is closed
144
- - :php:`topologyOpening() <mongodb-driver-monitoring-sdamsubscriber.topologyopening>`: Called
145
- when the topology is opened
141
+ class, define each ``SDAMSubscriber`` method. The following
142
+ table describes these methods and the command events they receive
143
+ notifications for:
144
+
145
+ .. list-table::
146
+ :header-rows: 1
147
+ :widths: 20 20 60
148
+
149
+ * - Method
150
+ - SDAM Event
151
+ - Description
152
+
153
+ * - :php:`serverChanged() <mongodb-driver-monitoring-sdamsubscriber.serverchanged>`
154
+ - :php:`ServerChangedEvent <class.mongodb-driver-monitoring-serverchangedevent>`
155
+ - Called when a server's description changes
156
+
157
+ * - :php:`serverClosed() <mongodb-driver-monitoring-sdamsubscriber.serverclosed>`
158
+ - :php:`ServerClosedEvent <class.mongodb-driver-monitoring-serverclosedevent>`
159
+ - Called when a server is removed from the topology
160
+
161
+ * - :php:`serverHeartbeatFailed() <mongodb-driver-monitoring-sdamsubscriber.serverheartbeatfailed>`
162
+ - :php:`ServerHeartbeatFailedEvent <class.mongodb-driver-monitoring-serverheartbeatfailedevent>`
163
+ - Called when a server heartbeat is unsuccessful
164
+
165
+ * - :php:`serverHeartbeatStarted() <mongodb-driver-monitoring-sdamsubscriber.serverheartbeatstarted>`
166
+ - :php:`ServerHeartbeatStartedEvent <class.mongodb-driver-monitoring-serverheartbeatstartedevent>`
167
+ - Called when the server receives a heartbeat
168
+
169
+ * - :php:`serverHeartbeatSucceeded() <mongodb-driver-monitoring-sdamsubscriber.serverheartbeatsucceeded>`
170
+ - :php:`ServerHeartbeatSucceededEvent <class.mongodb-driver-monitoring-serverheartbeatsucceededevent>`
171
+ - Called when a server heartbeat succeeds
172
+
173
+ * - :php:`serverOpening() <mongodb-driver-monitoring-sdamsubscriber.serveropening>`
174
+ - :php:`ServerOpeningEvent <class.mongodb-driver-monitoring-serveropeningevent>`
175
+ - Called when a new server is added to the topology
176
+
177
+ * - :php:`topologyChanged() <mongodb-driver-monitoring-sdamsubscriber.topologychanged>`
178
+ - :php:`TopologyChangedEvent <class.mongodb-driver-monitoring-topologychangedevent>`
179
+ - Called when the topology description changes
180
+
181
+ * - :php:`topologyClosed() <mongodb-driver-monitoring-sdamsubscriber.topologyclosed>`
182
+ - :php:`TopologyClosedEvent <class.mongodb-driver-monitoring-topologyclosedevent>`
183
+ - Called when the topology is closed
184
+
185
+ * - :php:`topologyOpening() <mongodb-driver-monitoring-sdamsubscriber.topologyopening>`
186
+ - :php:`TopologyOpeningEvent <class.mongodb-driver-monitoring-topologyopeningevent>`
187
+ - Called when the topology is opened
146
188
147
189
The following code creates the ``MySDAMSubscriber`` class, which implements
148
190
the ``SDAMSubscriber`` interface. The class defines each ``SDAMSubscriber`` method
@@ -195,8 +237,7 @@ record the events and output messages such as the following:
195
237
Remove a Subscriber
196
238
-------------------
197
239
198
- Later in your application, you might not want to subscribe to
199
- SDAM events. To unregister a subscriber from your client, use the
240
+ To unregister a subscriber from your client, use the
200
241
``MongoDB\Client::removeSubscriber()`` method.
201
242
202
243
The following code shows how to remove the subscriber created in
0 commit comments