You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add api registry and allow it to be added into client config in data source plugin (#5895)
* add api registry and allow it to be added into client config
Signed-off-by: Lu Yu <[email protected]>
* add changelog
Signed-off-by: Lu Yu <[email protected]>
* add documentation for multi data source plugin api registry
Signed-off-by: Lu Yu <[email protected]>
* change to resolve promise before calling getQueryClient
Signed-off-by: Lu Yu <[email protected]>
---------
Signed-off-by: Lu Yu <[email protected]>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
40
40
-[Multiple Datasource] Add datasource picker to import saved object flyout when multiple data source is enabled ([#5781](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5781))
41
41
-[Multiple Datasource] Add interfaces to register add-on authentication method from plug-in module ([#5851](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5851))
42
42
-[Multiple Datasource] Able to Hide "Local Cluster" option from datasource DropDown ([#5827](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5827))
43
+
-[Multiple Datasource] Add api registry and allow it to be added into client config in data source plugin ([#5895](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5895))
Copy file name to clipboardExpand all lines: docs/multi-datasource/client_management_design.md
+25-1
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,8 @@ This design is part of the OpenSearch Dashboards multi data source project [[RFC
10
10
2. How to expose data source clients to callers through clean interfaces?
11
11
3. How to maintain backwards compatibility if user turn off this feature?
12
12
4. How to manage multiple clients/connection efficiently, and not consume all the memory?
13
+
5. Where should we implement the core logic?
14
+
6. How to register custom API schema and add into the client during initialization?
13
15
14
16
## 2. Requirements
15
17
@@ -87,6 +89,20 @@ Current `opensearch service` exists in core. The module we'll implement has simi
87
89
2. We don't mess up with OpenSearch Dashboards core, since this is an experimental feature, the potential risk of breaking existing behavior will be lowered if we use plugin. Worst case, user could just uninstall the plugin.
88
90
3. Complexity wise, it's about the same amount of work.
89
91
92
+
**6.How to register custom API schema and add into the client during initialization?**
93
+
Currently, OpenSearch Dashboards plugins uses the following to initialize instance of Cluster client and register the custom API schema via the plugins configuration option.
94
+
```ts
95
+
core.opensearch.legacy.createClient(
96
+
'exampleName',
97
+
{
98
+
plugins: [ExamplePlugin],
99
+
}
100
+
);
101
+
```
102
+
The downside of this approach is the schema is defined inside the plugin and there is no centralized registry for the schema making it not easy to access. This will be resolved by implementing a centralized API schema registry, and consumers can add data source plugin as dependency and be able to consume all the registered schema, eg. `dataSource.registerCustomApiSchema(sqlPlugin)`.
103
+
104
+
The schema will be added into the client configuration when multi data source client is initiated.
105
+
90
106
### 4.1 Data Source Plugin
91
107
92
108
Create a data source plugin that only has server side code, to hold most core logic of data source feature. Including data service, crypto service, and client management. A plugin will have all setup, start and stop as lifecycle.
Since deprecating legacy client could be a bigger scope of project, multiple data source feature still need to implement a substitute for it as for now. Implementation should be done in a way that's decoupled with data source client as much as possible, for easier deprecation. Similar to [opensearch legacy service](https://github.com/opensearch-project/OpenSearch-Dashboards/tree/main/src/core/server/opensearch/legacy) in core.
165
+
Since deprecating legacy client could be a bigger scope of project, multiple data source feature still need to implement a substitute for it as for now. Implementation should be done in a way that's decoupled with data source client as much as possible, for easier deprecation. Similar to [opensearch legacy service](https://github.com/opensearch-project/OpenSearch-Dashboards/tree/main/src/core/server/opensearch/legacy) in core. See how to intialize the data source client below:
//equivalent when using data source client instead
176
+
const response =client.callAPI(format, params);
177
+
```
178
+
155
179
### 4.3 Register datasource client to core context
156
180
157
181
This is for plugin to access data source client via request handler. For example, by `core.client.search(params)`. It’s a very common use case for plugin to access cluster while handling request. In fact data plugin uses it in its search module to get client, and I’ll talk about it in details in next section.
0 commit comments