Implement Pluggable OS Adapter

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Unknown
    • 7.2.0
    • Affects Version/s: None
    • Component/s: None
    • 3
    • Not Needed
    • None
    • Needed
    • Hide

      This PR introduced the concept of runtimes, so the Driver can be used in non-Nodejs environments. This work is ongoing, but this is the first public release of this experimental feature.

      Show
      This PR introduced the concept of runtimes, so the Driver can be used in non-Nodejs environments. This work is ongoing, but this is the first public release of this experimental feature.
    • None
    • None
    • None
    • None
    • None
    • None

      As a Developer
      I want the driver to use my injected os adapter.
      So that I can collect client metadata in environments without a native Node.js os module.

      User Experience

      • Driver uses provided os adapter instead of require('os').

      Acceptance Criteria

      Implementation Requirements

      • API Update: MongoClientOptions interface includes an optional, experimental property:
        /** @experimental */
        driverAdapters?: {
          os?: OsAdapter;
        }
      • Resolution Logic:
        • At options parsing time, resolve the provided options with defaults (nodejs OS module)
        • Store the property in an accessible place on the MongoClient
      • No Breaking Changes: The default path must result in the exact same native Node.js modules being loaded.
      • Remove import: remove require('os') from all places inside src folder.
      • Use os adapter provided with the mongo client options.
      • Add `os` as a restricted eslint import

      Testing Requirements

        • Instantiate new MongoClient() (no options). Assert that client['runtime'].os is strictly equal to the native require('os') module.
        • Instantiate new MongoClient(..., { driverAdapters: { os: mockOs }}). Assert that client['runtime'].os equals mockOs.
      • ensure existing integration tests pass

      Documentation Requirements

      • n/a

      Follow Up Requirements

      • n/a

            Assignee:
            Bailey Pearson
            Reporter:
            Sergey Zelenov
            Pavel Safronov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: