[COMPASS-5207] Refactor dataService.instance method to simplify the data fetching code flow Created: 20/Oct/21  Updated: 29/Oct/23  Resolved: 02/Nov/21

Status: Closed
Project: Compass
Component/s: Data Service
Affects Version/s: None
Fix Version/s: 1.29.5

Type: Task Priority: Major - P3
Reporter: Sergey Petushkov Assignee: Sergey Petushkov
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to COMPASS-6595 Initial ping command does not inherit... Closed
Epic Link: COMPASS-4764
Story Points: 2
Documentation Changes: Not Needed
Sprint: Iteration Novokuybyshevsk, Iteration Orlando

 Description   

Currently it's pretty hard to make changes to dataService.instance method due to the code using outdated async library for flow control. Even though at some point this was the best approach, we can simplify the code a lot by refactoring it to async/await. This will allow us to make changes to the method easier later down the road

maurizio.casimirri did a POC refactor that can be a good starting point

Note: in scope of this ticket we DO NOT want to change the method behavior, it should still resolve all the data as it was doing before, these changes will come later

Miro board with changes context



 Comments   
Comment by Githook User [ 27/Oct/21 ]

Author:

{'name': 'Sergey', 'email': 'petushkov.sergey@gmail.com', 'username': 'gribnoysup'}

Message: chore(mongodb-data-service): Refactor `dataService.instance` method COMPASS-5207 (#2541)

  • feat(mocha-config-compass): Allow to run tests against arbitrary specs
  • chore(data-service): Clean up mocha config and allow es2020 in tsconfig
  • chore(data-service): Refactor instance-helper
  • Clean up async flow
  • Remove unused properties from bulid/host info
  • Stricter auto types for running server commands

Co-Authored-By: Maurizio Casimirri <maurizio.cas@gmail.com>

  • chore(instance-model): Clean up prop definitions following instance-helper refactor
  • chore: Rename enterprise_module to isEnterprise
  • chore(compass-metrics): Rename enterprise; Remove metric that is possibly always undefined
  • chore(data-service): No need to check for the error in `catch` callback, it's always there
  • chore(data-service): Bring back readPreference logic with a comment explaining why
  • chore(data-service): Remove unused options from instance method arguments
  • fix(data-service): Return errmsg from getCmdLineOptions command so that build-info library can detect "non-genuine" instances
  • test(data-service): Update instance-helper tests to include more cases with mocked client
  • test(data-service): Remove separate -mocked test file and add more tests for the instance-helper
  • fix(data-service): Change the call signature for instance method in tests; Fix depcheck

Co-authored-by: Maurizio Casimirri <maurizio.cas@gmail.com>
Branch: file-input-component
https://github.com/mongodb-js/compass/commit/c8f106f643f5cd216c7b8ca3271b5d41de241be9

Comment by Githook User [ 26/Oct/21 ]

Author:

{'name': 'Sergey', 'email': 'petushkov.sergey@gmail.com', 'username': 'gribnoysup'}

Message: chore(mongodb-data-service): Refactor `dataService.instance` method COMPASS-5207 (#2541)

  • feat(mocha-config-compass): Allow to run tests against arbitrary specs
  • chore(data-service): Clean up mocha config and allow es2020 in tsconfig
  • chore(data-service): Refactor instance-helper
  • Clean up async flow
  • Remove unused properties from bulid/host info
  • Stricter auto types for running server commands

Co-Authored-By: Maurizio Casimirri <maurizio.cas@gmail.com>

  • chore(instance-model): Clean up prop definitions following instance-helper refactor
  • chore: Rename enterprise_module to isEnterprise
  • chore(compass-metrics): Rename enterprise; Remove metric that is possibly always undefined
  • chore(data-service): No need to check for the error in `catch` callback, it's always there
  • chore(data-service): Bring back readPreference logic with a comment explaining why
  • chore(data-service): Remove unused options from instance method arguments
  • fix(data-service): Return errmsg from getCmdLineOptions command so that build-info library can detect "non-genuine" instances
  • test(data-service): Update instance-helper tests to include more cases with mocked client
  • test(data-service): Remove separate -mocked test file and add more tests for the instance-helper
  • fix(data-service): Change the call signature for instance method in tests; Fix depcheck

Co-authored-by: Maurizio Casimirri <maurizio.cas@gmail.com>
Branch: compass-home-ts
https://github.com/mongodb-js/compass/commit/c8f106f643f5cd216c7b8ca3271b5d41de241be9

Comment by Githook User [ 26/Oct/21 ]

Author:

{'name': 'Sergey', 'email': 'petushkov.sergey@gmail.com', 'username': 'gribnoysup'}

Message: chore(mongodb-data-service): Refactor `dataService.instance` method COMPASS-5207 (#2541)

  • feat(mocha-config-compass): Allow to run tests against arbitrary specs
  • chore(data-service): Clean up mocha config and allow es2020 in tsconfig
  • chore(data-service): Refactor instance-helper
  • Clean up async flow
  • Remove unused properties from bulid/host info
  • Stricter auto types for running server commands

Co-Authored-By: Maurizio Casimirri <maurizio.cas@gmail.com>

  • chore(instance-model): Clean up prop definitions following instance-helper refactor
  • chore: Rename enterprise_module to isEnterprise
  • chore(compass-metrics): Rename enterprise; Remove metric that is possibly always undefined
  • chore(data-service): No need to check for the error in `catch` callback, it's always there
  • chore(data-service): Bring back readPreference logic with a comment explaining why
  • chore(data-service): Remove unused options from instance method arguments
  • fix(data-service): Return errmsg from getCmdLineOptions command so that build-info library can detect "non-genuine" instances
  • test(data-service): Update instance-helper tests to include more cases with mocked client
  • test(data-service): Remove separate -mocked test file and add more tests for the instance-helper
  • fix(data-service): Change the call signature for instance method in tests; Fix depcheck

Co-authored-by: Maurizio Casimirri <maurizio.cas@gmail.com>
Branch: 1.29-releases
https://github.com/mongodb-js/compass/commit/c8f106f643f5cd216c7b8ca3271b5d41de241be9

Comment by Githook User [ 26/Oct/21 ]

Author:

{'name': 'Sergey', 'email': 'petushkov.sergey@gmail.com', 'username': 'gribnoysup'}

Message: chore(mongodb-data-service): Refactor `dataService.instance` method COMPASS-5207 (#2541)

  • feat(mocha-config-compass): Allow to run tests against arbitrary specs
  • chore(data-service): Clean up mocha config and allow es2020 in tsconfig
  • chore(data-service): Refactor instance-helper
  • Clean up async flow
  • Remove unused properties from bulid/host info
  • Stricter auto types for running server commands

Co-Authored-By: Maurizio Casimirri <maurizio.cas@gmail.com>

  • chore(instance-model): Clean up prop definitions following instance-helper refactor
  • chore: Rename enterprise_module to isEnterprise
  • chore(compass-metrics): Rename enterprise; Remove metric that is possibly always undefined
  • chore(data-service): No need to check for the error in `catch` callback, it's always there
  • chore(data-service): Bring back readPreference logic with a comment explaining why
  • chore(data-service): Remove unused options from instance method arguments
  • fix(data-service): Return errmsg from getCmdLineOptions command so that build-info library can detect "non-genuine" instances
  • test(data-service): Update instance-helper tests to include more cases with mocked client
  • test(data-service): Remove separate -mocked test file and add more tests for the instance-helper
  • fix(data-service): Change the call signature for instance method in tests; Fix depcheck

Co-authored-by: Maurizio Casimirri <maurizio.cas@gmail.com>
Branch: main
https://github.com/mongodb-js/compass/commit/c8f106f643f5cd216c7b8ca3271b5d41de241be9

Generated at Wed Feb 07 22:38:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.