-
Type:
Improvement
-
Resolution: Gone away
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: libmongoc
The event structs passed to SDAM monitoring callbacks are const, e.g.:
typedef void (*mongoc_apm_topology_changed_cb_t) ( const mongoc_apm_topology_changed_t *event);
Furthermore, the event accessors give const pointers:
MONGOC_EXPORT (const mongoc_topology_description_t *) mongoc_apm_topology_changed_get_previous_description ( const mongoc_apm_topology_changed_t *event);
However, mongoc_topology_description_has_readable_server / writable server take non-const mongoc_topology_description_t pointers, because they must perform server selection which is a non-const operation on the topology description.
Calling mongoc_topology_description_has_readable_server / writable_server on the topology description provided to an SDAM monitoring callback is a documented use case in the SDAM monitoring spec, it shouldn't require the user to cast away const.
We can de-const some types without breaking compatibility.
Since we provide no public setter functions for any event structs, we could de-const them all without changing semantics significantly, and keep all the callback signatures consistent. Let's consider doing that.