OpenSearch icon indicating copy to clipboard operation
OpenSearch copied to clipboard

Code Duplication in Cloud Plugins

Open kartg opened this issue 3 years ago β€’ 7 comments

Is your feature request related to a problem? Please describe. There seems to be duplication of logic in the code for Cloud Plugins. This is an opportunity for us to streamline the codebase and refactor these classes. This issue stems from these comments in #2096.

Describe the solution you'd like Move common functionality to superclasses and have the Cloud Plugins inherit/extend these in platform-specific subclasses.

Describe alternatives you've considered N/A

Additional context N/A

kartg avatar Feb 17 '22 19:02 kartg

Small investigation I made.

Common code I found: List of common classes and functions for proxy settings in all cloud plugins:

  • ProxySettings - could be a generic type, since all clients have they own ProxyType
  • *Settings classes - the function validateAndCreateProxySettings has the same code for all plugins Common functions:
  • all *Settings::getConfigValue and *Settings::getValue classes use the same logic to get settings

Common settings:

  • client
  • compress
  • readonly
  • chunk_size
  • base_path
  • all proxy stettings

Common class:

  • SocketAccess - it is the same for all plugins

I think it is possible to build high level abstraction for the plugin and re-use it in plugins. I tried to do it here https://github.com/aiven/aiven-repositories-for-opensearch, the code is far from ideal, maybe you will find it usefull.

willyborankin avatar Feb 21 '22 16:02 willyborankin

@CEHENKLE and @kartg if you are still interested in refactoring cloud repositories. I can help with it. Wdyt?

willyborankin avatar May 28 '22 15:05 willyborankin

@willyborankin we're definitely still interesting in refactoring these plugins. Would you be willing to attempt a first pass with one of the plugins, and we can iteratively refactor the rest?

kartg avatar Jun 03 '22 20:06 kartg

Sure will prepare PR during this week

willyborankin avatar Jun 08 '22 08:06 willyborankin

Hello @kartg . This issue seems to be a nice start to my open source contribution journey. Can you please assign this to me?

sourav25998 avatar Sep 10 '22 10:09 sourav25998

@sourav25998 i don’t think we can use assignments on GH due to permissions, but go for it! Make a PR

dblock avatar Sep 13 '22 19:09 dblock

@dblock πŸ‘† πŸ˜‰

kartg avatar Sep 14 '22 17:09 kartg