OpenSearch-Dashboards icon indicating copy to clipboard operation
OpenSearch-Dashboards copied to clipboard

[MDS] Refactor several utility functions in data source plugin

Open huyaboo opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe. Currently, there are two functions being repeated in plugins that can simply be extracted into data source plugin utility functions:

  • A function that decides whether to use local cluster or remote OpenSearch client based on data source id
  • A function that retrieves the data source id based on data source title/name

Describe the solution you'd like There should be three utility functions placed in the data source plugin that will be exposed so that other plugins can consume:

  • decideClient(context: RequestHandlerContext, dataSourceId?: string, withLongNumeralsSupport: boolean): return the correct client
  • decideLegacyClient(context: RequestHandlerContext, dataSourceId?: string): return the correct legacy client
  • fetchDataSourceNameById(client: SavedObjectsClientCommon, dataSourceTitle: string): return the data source id (if it exists)
    • SavedObjectClientWrapper should be defined in both public and server folders for passing type checks

Describe alternatives you've considered

N/A

Additional context

N/A

huyaboo avatar Apr 11 '24 23:04 huyaboo