Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See https://github.com/lampepfl/gears
Currently sttp-client defines a couple of backend types:
SyncBackend
,Backend[F[_]]
,WebSocketSyncBackend
,StreamBackend[F[_], +S]
,WebSocketStreamBackend[F[_], S]
.They all inherit from a
GenericBackend[F[_], +P]
(where P are supported sttp-capabilities, such as streaming and websockets), but sttp has specialisied "concrete" types for better auto-complete and general developer experience.My first first thought was to add a
CapabilityBackend[C]
to the hierarchy, but this would mean also adding a WebSocket/Streaming variants, and adding the new variants for all generic backend wrappers. This would additionally complicate the already complicated setup.So instead, I went with representing the "Gears effect" as a type constructor (I called it
Deferred
), and usingBackend[F[_]]
:One thing that is not ideal is the
.send
variant that I had to add, which would work for any capability:This is needed so that both of these compile:
(without it only the second, not-explicitly-typed one compiles)
I also tried adding a gears-specific extension method (which would have a
using Async
, instead of the generic formulation above), but unfortunately the.send
methods defined directly in theRequest
class have priority, so this method was never taken into consideration.Anyway, summing up, to add gears integration into sttp-client with the approach above, we have to:
.send
variant