by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 07 05:02
    scala-steward opened #1251
  • Aug 06 10:13
    codecov-commenter commented #1250
  • Aug 06 10:07
    keyno63 opened #1250
  • Aug 02 16:22
    codecov-commenter commented #1215
  • Aug 02 16:16
    codecov-commenter commented #1215
  • Aug 02 16:16
    scala-steward synchronize #1215
  • Aug 02 15:11
    rpless closed #1241
  • Aug 02 15:11
    rpless commented #1241
  • Aug 02 15:07

    rpless on master

    Update cats-core, cats-laws to … (compare)

  • Aug 02 15:07
    rpless closed #1210
  • Aug 02 15:03
    codecov-commenter commented #1210
  • Aug 02 14:57

    rpless on master

    Update finagle-http, finagle-st… (compare)

  • Aug 02 14:57
    rpless closed #1247
  • Aug 02 14:56
    codecov-commenter commented #1210
  • Aug 02 14:56
    rpless synchronize #1210
  • Aug 02 14:50
    rpless closed #1209
  • Aug 02 14:50
    rpless commented #1209
  • Aug 02 14:50
    rpless closed #1124
  • Aug 02 14:50
    rpless commented #1124
  • Aug 02 14:34
    rpless closed #1205
Sergey Kolbasov
@sergeykolbasov

Hi

No, sadly there is no tool to derive swagger from Finch endpoints

Frederick Cai
@zhenwenc
I found this lib (https://github.com/softwaremill/tapir) seems can be a good candidate. May require documenting each endpoints manually, but their syntax looks very similar to Finch(x).
Georgi Krastev
@joroKr21
Would be nice for someone to add a Finch interpreter to tapir :D
Sergey Kolbasov
@sergeykolbasov
I would say, straight to Finagle service then
Frederick Cai
@zhenwenc
Hmm...
Ryan Plessner
@rpless
yeah I'd say Tapir directly to Finagle is the way to go if you want to leverage Tapir. it also seems like they have a Finatra interpreter
Larry Bordowitz
@lbordowitz
What's the point of item in Endpoint?
Vladimir Kostyukov
@vkostyukov
It’s used for generating a more useful Error instance
Larry Bordowitz
@lbordowitz
Anything else?
Vladimir Kostyukov
@vkostyukov
I don’t think so. I personally wanted to remove them for a long time but haven’t figured a better way to propagate this meta information down to an Error instance.
Larry Bordowitz
@lbordowitz
I was thinking of implementing an item-like Monad to collect information for specification documents like OpenAPI
Sorta expanding the scope of item instead of removing it, sorry :P
Vladimir Kostyukov
@vkostyukov
Yeah, I think Sergey was experimenting with this as well. finagle/finch#880
Larry Bordowitz
@lbordowitz
That's a really nice pointer, thank you for that! Should it be a separate field like meta, or expand item?
Maksym
@ratoshniuk

Hi there!

I am currently trying to use finch but got some issues with understanding of it's abstractions

I have multiple services and want to combine them while bootrstrapping

its it possible to do?

for example


val svc1: Service[Request, Response] = ???
val svc2:  Service[Request, Response] = ???

Http.server.serve(":8080", svc1 :+: svc2)
thanks for any help!
Sergey Kolbasov
@sergeykolbasov

Hi @ratoshniuk

Could you elaborate how did you end up with two Finagle services?

Usually, in finch you would combine Endpoints first using :+: operator, and only after that convert it to Finagle service, so routing would be handled for you.

If it's crucial to have multiple services, take a look at twitter-server HttpMuxer:
https://github.com/twitter/twitter-server/blob/master/server/src/test/scala/com/twitter/server/util/HttpUtilsTest.scala

Though you would need to handle routing there manually

Dermot Haughey
@hderms
@sergeykolbasov if you want finagle filters to only be applied to certain endpoints, but not others, wouldn't that imply you need separate finagle services?
we had an issue like that in the past which we resolved by having multiple finagle services (which we got rid of by writing a more finch-centric way of doing authorization/authentication)
Larry Bordowitz
@lbordowitz
Is there a way to make a list of endpoints, to use in a foreach and then also to "fold" (or something) into a coproduct?
Larry Bordowitz
@lbordowitz
Nevermind
Frederick Cai
@zhenwenc
@lbordowitz I had the same wonder earlier hah! Have you managed to find the solution?
Sergey Kolbasov
@sergeykolbasov
It's possible only under the condition of endpoints sharing the same type
Then you can use Endpoint.coproduct method
Otherwise welcome to the beautiful world of shapeless, type level programming and all the rest of things we love
Georgi Krastev
@joroKr21
Hmm, it would be nice to have Endpoint.coproduct[A](endpoints: Endpoint[A]*)
I checked now and we have only endpointA coproduct endpointB
Larry Bordowitz
@lbordowitz
@zhenwenc I'm working on adding metadata to finch for auto-generation of REST API specification documents. So, instead of working with the coproduct directly, I just created a recursive list-like datastructure in my metadata and shoved the two parts of the coproduct into there.
Dermot Haughey
@hderms
@lbordowitz interested to see how this turns out. The big weakness with all the auto-documenting stuff I've seen so far is what happens when you have a JSON body or JSON response. I'm not sure that's doable in a general sense with something like circe given that custom encoders/decoders are relied upon relatively frequently in practice and I'm not sure if there is an ideal solution for documenting them automatically given they can execute arbitrary code. Also I don't think you can tell a derived codec from a manually implemented one so I'm not confident that libraries could handle it properly. Let me know if you have any ideas because that ended up being one of the big roadblocks I identified
Georgi Krastev
@joroKr21
Well you can't use Circe or other JSON-only codecs. You would need another typeclass perhaps for schemas but the problem is keeping it in sync with the codecs. Btw that's one reason why I prefer (semi) auto generated codecs. I don't understand why people shy away from that. As long as you have separate data types to keep your API layer isolated from your internal logic, it's all fine.
Larry Bordowitz
@lbordowitz
@hderms the goal isn't automatic derivation of everything, just low touch. So, you get the type when you make a jsonBody, and it's decodable; can we get enough metadata to derive a json object schema? What if it's just for standard case classes? And, yeah, definitely more than a little stuck on body encoding right now. Regarding responses, I had an idea of a sort of "test harness" like runner, which could generate documented examples and maybe even output types. It's a bit pie-in-the-sky, tho, cuz I don't know a lot of the reflection and fancy tricks these serialization libraries (like Circe) use to do what they do.
Dermot Haughey
@hderms
yeah i'm not confident anything like that could work with circe without breaking as soon as you introduce your own custom encoder/decoder
i'm not an authority on the subject though
Larry Bordowitz
@lbordowitz
Oh, it won't work at all on a custom encoder/decoder. That's fine by me for now, I'm just working on a Proof-of-Concept. If it works for me, then at least I'll have something to show for it. Regarding auto derivation, I think rather than plugging into circe or any encoder in particular, it should just use the same fancy macro/implicit logic like how circe uses, but instead of encoding objects of those types, getting a metadata schema of that type.
Larry Bordowitz
@lbordowitz
In fact I've found this project which uses shapeless to great effect in generating a JSON schema out of a case class. It's unmaintained, but MIT licensed, and the code matches the other shapeless documentation that I've found. https://github.com/timeoutdigital/docless/blob/master/src/main/scala/com/timeout/docless/schema/derive/HListInstances.scala I'll try incorporating this and some smarter recursive logic in the metadata consolidation.
Dmitry Avdonkin
@oviron
Hey guys!
I've got a question about error handling in Finch.
For the last couple of years i've been doing it with the good ol' Finagle filter. It allows me to log error, log request and return failed response.
I've tried to use Endpoint.handle instead, but it means i cant log request in case of error anymore.
Is there any other more modern and finch-style way to do it?
Sergey Kolbasov
@sergeykolbasov
If you use finchx, you can do it on the Endpoint.Compiled level

https://github.com/finagle/finch/blob/master/examples/src/main/scala/io/finch/middleware/Main.scala

Handling all the errors inside of Kleisli, so roughly the same as finagle filter

Good thing that Finch itself makes its best to guarantee that F[(T, Either[Throwable, Response])] won't throw on itself, so it's enough to handle the left case of this Either
Dermot Haughey
@hderms
@sergeykolbasov do you know if it's possible to make that work while also passing an argument into an endpoint?
one of the big obstacles for us getting off finagle filters is we want to have a filter which sets a request id on the request object before any application code is run
then we want to configure a logger that has the request ID as a parameter
the way I accomplish that currently is with a finagle filter that runs before everything and sets a random request ID on finagle Request
then I have an endpoint based on root which can pull out that request ID, configure the logger and return the logger. I call it withRequestLogger
and then I use it like
post("foo" :: withRequestLogger) { logger: Logger =>
this does everything we want but it has the undesirable side effect of putting logger in lots of type signatures (which is debatably a positive)
and in addition requires understanding of finagle filters