-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MD]Research on opensearch_service.ts and client management to determine the connection strategy to support multiple datasource #1721
Comments
The solid truth is we need create multiple clients, which hold multiple connections in order to talk to multiple OpenSearch clusters. The problems are: 1. Where to initialize the client?2. How to manage clients in an efficient way? (Out of discussion scope of this thread)While my previous poc #1499 doesn't come up with a clear solution for question number 2, but it provides some insights on question number 1. Let's first take a look at how default OpenSearch-Dashboards/src/plugins/data/server/search/opensearch_search/opensearch_search_strategy.ts Line 75 in beb46f5
OpenSearch-Dashboards/src/core/server/opensearch/client/scoped_cluster_client.ts Lines 55 to 60 in 89d3872
To support multiple datasource, we also need a way to create and retrieve multiple clients. And there are 2 options 1. initialize client in data plugin - >
|
const client = new Client({ | |
node: url, | |
auth: { | |
username, | |
password, | |
} | |
}); |
2. initialize client in core, and expose core apis for modules to retrieve clients. Similar to what I did in the poc zengyan-amazon#2
The second approach is preferred for the following reasons.
- it follows the similar paradigm of default search strategy, it can be accessible from core by something similar to
context.core.opensearch.dataSourceClient.asDataSourceUser.search(param)
- When other internal and external plugins wants to leverage multi datasource feature, it will have a much cleaner interface to just call
cotext.core.dataSourceClient
. Giving an example of how external OSD plugins is using default opensearch client
https://github.com/opensearch-project/dashboards-reports/blob/73331021e8e496f82fa80c15d7258ae18fba319d/dashboards-reports/server/routes/reportDefinition.ts#L53 - Having it decoupled from data plugin enables us more flexibility when implementing features of clients, such as client pooling, or onboarding other types of datasources(that requires different types of clients). Because we decouple the
search
(data pugin) andclient management
(OSD core) logically.
Furthermore, a bit about implementation. We can
- Wire it in the existing
core -> opensearch_service
, similar as scoped client creation - Or we can just create a new service called
datasource_service
in core.
As for which one is better, it's implementation level that we can decide later.
Thanks @zhongnansu for putting information together. I like the preferred solution to initialize client in core api which could be used by other plugins without change too much code. Here is my thoughts about below
create a new
@zengyan-amazon any comments?
@zhongnansu other than above open question, are we clear to close this research task with conclusion and move to design and implementation phase? |
@zhongnan to fill in detail
The text was updated successfully, but these errors were encountered: