getkyo / kyo

Toolkit for Scala Development
https://getkyo.io
Apache License 2.0
518 stars 43 forks source link

Routes: Http Server via Tapir #175

Closed danslapman closed 5 months ago

danslapman commented 7 months ago

Hi! Being pretty impressed with kyo's features i tried to migrate one of my application from ZIO to KYO. Since it is a tapir-based backend the first thing i needed was to implement some kind of tapir-kyo integration module. Result of my attempt can be found here. sttp's design relies on MonadError, so, I decided to bound my effect with Aborts. Here came the first problem - Flat's: it's impossible to add an extra bound to an arbitrary typeclass method. For the experiment I ended up with Flat.unsafe.unchecked. On the next step I finally stuck with another problem - Tag's, which again couldn't be provided.

Am I mistaken in the way I designed my instances? While it's not entirely necessary - I agree we can get rid of tapir and build an application without cats/scalaz/whatever, I think it's good to have a way to live side-by-side.

Anyway, thanks for the fantastic effort on KYO, Quill and all other brilliant libraries!

fwbrasil commented 7 months ago

Thanks for the feedback! It's odd that I haven't seen bug reports yet, did you encounter any?

I'm also in need of an HTTP server for Kyo. Did you see the initial integration in the repo? It uses this monad definition from the sttp module but it also relies on Flat.unsafe for error handling.

I'll take a look if it'd be possible to avoid the flat check for error handling (Tries.run). It's a common operation and ends up making the check appear in several unexpected places.

danslapman commented 7 months ago

Thanks @fwbrasil, I definitely missed that code 😅 I will try to adopt it. As for bugs - I didn't encounter something yet, I'll report back after minimal working rewrite

fwbrasil commented 6 months ago

@danslapman I used Kyo for a performance benchmark challenge and finalized the initial version of the Tapir integration for it. I've submitted a few optimizations to Tapir as well. The documentation for the module is still missing but you can take a look at the usage here: https://github.com/fwbrasil/rinha-2024-q1/tree/main/src/main/scala/rinha

fwbrasil commented 5 months ago

Closing in favor of https://github.com/getkyo/kyo/issues/219