Alter ClientMetadata and mark as internal + remove extendedClientMetadata option from codebase

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • 1
    • Not Needed
    • None
    • 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

      User Story

      As a driver engineer,
      I want the MongoClient's cached client metadata to be internal,
      So that I modify it without worrying about semver.

      As a driver engineer,
      I want to remove the legacy `metadata` property on the MongoClient that is no longer used in favor of the `extendedMetadata` and rename `extendedMetadata` as `metadata`,
      So that I only have a single source of client metadata per mongoclient.

      Background: Prior to NODE-5454, client metadata was built synchronously during options parsing and stored on the MongoClient. NODE-5454 required file access, which necessitated async code. The solution we chose was to instead cache a promise that resolves to client metadata on the MongoClient and await it where we use it (this occurs in `connect()`, which is asynchronous).

      However, for whatever reason, `MongoClient.metadata` is public so we could not modify this property to change it to a promise. So, we added a field called `extendedMetadata` on the MongoClient. Now the MongoClient stores two fields:

        metadata: ClientMetadata;
        /** @internal */
        extendedMetadata: Promise<Document>;
      

      We currently construct these options like so:

        mongoOptions.metadata = makeClientMetadata(mongoOptions);
      
        mongoOptions.extendedMetadata = addContainerMetadata(mongoOptions.metadata).then(
          undefined,
          squashError
        ); // rejections will be handled later
      

      As a part of this ticket we would like to:

      1. remove the unused `metadata` property from the MongoClient and instead store the metadata promise as `metadata`.
      2. make sure the interface `ClientMetadata` is accurate and includes container runtime fields (I don't think it does now)
      3. make the ClientMetadata interface private
       

       

      User Impact

      • should be none, unless users are using the `metadata` property (I can't see why they would?)

      Acceptance Criteria

      Implementation Requirements

      • Mark ClientMetadata interface as internal
      • Audit the ClientMetadata metadata interface to make sure it is accurate and matches the spec. Fix any errors encountered.
      • Remove the `metadata` property from the MongoClient and rename `extendedMetadata` as `metadata` on the client. (this will require a few code changes, TS should catch this. anywhere we use `extendedMetadata` needs to be updated).
      • Move container metadata logic into makeClientMetadata

      Testing Requirements

      • Make sure existing tests pass

      Documentation Requirements

      • n/a

            Assignee:
            Bailey Pearson
            Reporter:
            Aditi Khare (Inactive)
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: