opensearch-java icon indicating copy to clipboard operation
opensearch-java copied to clipboard

Add sample to create the client via dynamic proxy

Open HEskandari opened this issue 1 year ago • 4 comments

Description

Add a sample on how to create the OpenSearchClient through DynamicProxy. This allows users to add custom logic around the client operations for cross-cutting concerns such as added logging, exception handling, or introducing delays and failures for testing purposes.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check here.

HEskandari avatar Feb 15 '24 00:02 HEskandari

Hey @HEskandari, I believe this example does not belong here. Any kind of proxying / class rewrite / instrumentation ... is not the concern of OpenSearch Java Client but the framework or application that uses these techniques (hopefully, for reasons). In this regard, the OpenSearch Java Client APIs are no different than any other APIs out there.

reta avatar Feb 15 '24 01:02 reta

@reta does it hurt to have it here? should it just be a SO or maybe someone's blog post? I'd be happy to have it on mine ;)

dblock avatar Feb 15 '24 14:02 dblock

@reta does it hurt to have it here? should it just be a SO or maybe someone's blog post? I'd be happy to have it on mine ;)

Sure @dblock , but do you really want that? There are few things to keep in mind: JDK releases easily break that (cglib has not been updated for the last 2 years, 3.3.0 was out in 2019). This is very shaky ground for the library whose business is not that ...

reta avatar Feb 15 '24 14:02 reta

Yeah, I think I agree :(

dblock avatar Feb 15 '24 15:02 dblock

Moved the example here for whoever is interested. Closing.

HEskandari avatar Jun 05 '24 20:06 HEskandari

Thanks for contributing the sample @HEskandari !

dblock avatar Jun 05 '24 20:06 dblock