Pass non-const event structs to APM callbacks

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Gone away
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: libmongoc
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      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.

        1. patch
          37 kB
          A. Jesse Jiryu Davis

            Assignee:
            Unassigned
            Reporter:
            A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: