opensearch-project / opensearch-sdk-java

OpenSearch SDK to build and run extensions
Apache License 2.0
28 stars 59 forks source link

[PROPOSAL] Redesign the SDKClient #732

Open dbwiddis opened 1 year ago

dbwiddis commented 1 year ago

What/Why

What are you proposing?

We should redesign the SDKClient from scratch, without referring to the existing client which is trying to do too many things and doing some of them poorly.

Our original vision (if we ever had one) for the SDKClient has morphed over time into an increasingly unmaintainable pile of spaghetti code. It looks like we started wanting to use it just as a wrapper for the OpenSearch Client for Java (opensearch-java), but then:

Core capabilities we need:

What users have asked for this feature?

612, #729, #430, #616, TBD issue on serverless

What problems are you trying to solve?

Replace existing usages of NodeClient implementations in plugins, specifically

What is the developer experience going to be?

For migrating existing plugins, a minimal diff.

For developing new plugins, a set of clearly documented tools providing needed capabilities.

Why should it be built? Any reason not to?

Properly handle initialization Properly handle resource usage/leakage Properly handle multithreading Permit DRY

What will it take to execute?

Re-thinking/re-scoping what the object does and does not do.

Any remaining open questions?

dblock commented 1 year ago

I am a big fan of deferring client responsibilities to opensearch-java and taking a runtime dependency on it.

dbwiddis commented 1 year ago

I am a big fan of deferring client responsibilities to opensearch-java and taking a runtime dependency on it.

Can you be a little more specific what this means, @dblock ? Currently we don't do much with the opensearch-java client other than initialize it from our settings. We weren't planning on doing more; in fact, I'm proposing not depending on them or providing them at all and just giving a few lines of code a user can write themselves.

dblock commented 1 year ago

I think we're saying the same thing @dbwiddis. If an extension needs to make "standard" RESTful API calls to an OpenSearch instance it should know how, but not use the code in the SDK to do it.