elastic4s
elastic4s copied to clipboard
Explicit effect types
This addresses https://github.com/Philippus/elastic4s/issues/2379. Overall I deleted more code than I've added which is a good sign.
-
AkkaHttpClient
andPekkoHttpClient
were wrapping a lot ofFuture
's under the hood – this is now removed and looks much cleaner. -
JavaClient
now uses ScalaPromise/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 aroundFuture
monad's Sttp implementation – now allows any monads that are supported bySttp
, feels like a proper way to use it. -
Testkit
now explicitly define thatFuture
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 theClient
's level. I left them just to show that they are now obsolete, will be happy to remove them as well. - After removing
Executor
s, I tend to think thateffect-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 requirecats
dependency to reuseFunctor
that is now defined manually inelastic4s-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.