elastic4s icon indicating copy to clipboard operation
elastic4s copied to clipboard

Explicit effect types

Open igor-vovk opened this issue 7 months ago • 18 comments

This addresses https://github.com/Philippus/elastic4s/issues/2379. Overall I deleted more code than I've added which is a good sign.

  • AkkaHttpClient and PekkoHttpClient were wrapping a lot of Future's under the hood – this is now removed and looks much cleaner.
  • JavaClient now uses Scala Promise/Future mechanism that doesn't require any 3rd-party libraries and that was created to replace callback mechanisms, I think it is better this way
  • SttpRequestHttpClient was a wrapper around Future monad's Sttp implementation – now allows any monads that are supported by Sttp, feels like a proper way to use it.
  • Testkit now explicitly define that Future effect is used, which was used under the hood before as well, just not explicitly shown.
  • After the change Executor's became empty since all handling is now performed on the Client's level. I left them just to show that they are now obsolete, will be happy to remove them as well.
  • After removing Executors, I tend to think that effect-zio, effect-zio-1, effect-cats, effect-cats-2, effect-monix, effect-scalaz modules can be also removed as a future improvement (not sure about that, this may require cats dependency to reuse Functor that is now defined manually in elastic4s-core and that those modules implement).
  • ZIO tests are not compiling now because I don't know which ZIO client to use. But it doesn't make sense for me to have ZIO implementation without ZIO-based http clients, not sure what to do here.

I would add that the way the callback mechanism was defined and used looked like a big hack for me, that was maybe historically implemented because library started with only JavaClient? I didn't check this assumption, but overall, everything that Executor's and Client's were doing, is mapping from K[_] monad implemented by 3rd-party clients, through (Either[Throwable, A]) => Unit callback, to F[_] monad used on the top-level. So there was this clunky 3-step transformation that hidden a lot of stuff.

igor-vovk avatar Jul 17 '24 11:07 igor-vovk