Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 20 14:19
    scala-steward closed #1310
  • Jun 20 14:19
    scala-steward commented #1310
  • Jun 20 14:19
    scala-steward opened #1394
  • Jun 14 05:13
    codecov-commenter commented #1393
  • Jun 14 05:05
    scala-steward closed #1390
  • Jun 14 05:05
    scala-steward commented #1390
  • Jun 14 05:04
    scala-steward opened #1393
  • Jun 09 14:21
    scala-steward opened #1392
  • Jun 01 05:03
    scala-steward closed #1367
  • Jun 01 05:03
    scala-steward commented #1367
  • Jun 01 05:03
    scala-steward opened #1390
  • May 31 00:28
    codecov-commenter commented #1388
  • May 31 00:19
    scala-steward closed #1381
  • May 31 00:19
    scala-steward commented #1381
  • May 31 00:19
    scala-steward opened #1388
  • May 28 20:43
    codecov-commenter commented #1387
  • May 28 20:35
    scala-steward closed #1380
  • May 28 20:35
    scala-steward commented #1380
  • May 28 20:35
    scala-steward opened #1387
  • May 28 09:44
    scala-steward closed #1334
Christopher London
@Sicarius154

Hi all, I'm having some issues with CORS, it's my first time using Scala on an edge-service that communicates with a React client. Am I correct in thinking that using:

new Cors.HttpFilter(Cors.UnsafePermissivePolicy).andThen( (Bootstrap .serve[Application.Json]( ... .toService)

Will essentially disable CORS on the backend?

Marwan Rabbâa
@waghanza
Hi,
We try to add finch in the-benchmarker/web-frameworks#3675. This a benchmarking project. We care about having consent (or at least non-opposition) before doing such a thing. Do core dev / maintainers are not opposed of add finch in this list ?
Sergey Kolbasov
@sergeykolbasov
sure
Marwan Rabbâa
@waghanza
:heart:
Sergey Kolbasov
@sergeykolbasov
although, code looks a bit weird as to me
Marwan Rabbâa
@waghanza
honestly, I'm not a scala guy :stuck_out_tongue:, but feel free to review (that also a reason of asking for consent / approval)
Sergey Kolbasov
@sergeykolbasov

instead of

Bootstrap
      .serve[Text.Plain](root)
      .serve[Text.Plain](postUser)
      .serve[Text.Plain](getUserName)
      .toService

should be

Bootstrap
      .serve[Text.Plain](postUser :+: getUserName :+: root)
      .toService
I'll drop the comment in PR
Marwan Rabbâa
@waghanza
thanks
tpetillot
@tpetillot

Hi all!

Using Bootstrap.serve[Text.Html] on a endpoint containing finagle Response, content-type isn't added.
When added on response, it's alright, but then nothing should be specified on Bootstrap.serve which isn't possible.

From my understanding, serve[CT](A :: B :: CNil) compiled will look for io.finch.Encode types Aux[A, CT] and Aux[B, CT] if type isn't com.twitter.finagle.http.Response.

As it is a com.twitter.finagle.http.Response, CT should not be mandatory ?

What would be the right way ? I'm using scalatags, should I create an encoder for something like (Status, Option[TypedTag]) ?
How to serve Response without specifying content type as it's not use from Bootstrap ?

Sergey Kolbasov
@sergeykolbasov
hmm, it's a tricky one

from one hand, I understand your point on the lack of consistency

from the other hand, we don't want to mangle with user created Response as we assume they know what they're doing going with the low-level abstraction

so I'd say if you deal with responses directly, have it added there
although, in theory it's possible to check Content-Type header and update it if missing
tpetillot
@tpetillot
Thanks @sergeykolbasov , that's what I assume!
tpetillot
@tpetillot

Hi again ! I need confirmation, before doing anything else with HList:
If I have endpoints thare are different depending on a variable, let's say:

val condition: Boolean = ???
val a: Endpoint[F, A ::  ... :: CNil] = ???
val b: Endpoint[F, B :: ... :: CNil] = ???
val ab = if (condition) a else b

Is there a way to have an union type for the HList ? Am I required to compiled a and b ?

Sergey Kolbasov
@sergeykolbasov
they are different types, you need somehow to converge A and B into the same one, like map it into Either[A, B]
Sergey Kolbasov
@sergeykolbasov

other option is to build your own coproduct of Endpoint[(A :: ... HNil) :+: (B :: ... HNil) :+: CNil] using some kind of custom operator:

def conditional(condition: => Boolean)(a: Endpoint[A], b: Endpoint[B]): Endpoint[A :+: B]

but it's quite complicated

could you describe your specific problem, there might be another solution to it
tpetillot
@tpetillot

It's about different endpoints depending on the environment (related to identification).

environment match {
  case x => Endpoint[X :: ... HNil]
  case y => Endpoint[Y :: ... HNil]
  case z => Endpoint[Z :: ... HNil]
}

Current solution implemented define all the endpoints, with some path defined as empty.

This join 'somehow' your point of having the return type containing all the possible return types.
Endpoint[(X :: ... HNil) :+: (Y :: ... HNil) :+: (Z :: ... HNil)]

For now, I let the endpoint types inferred at compile time, which is why I didn't think about something like:

environment match {
  case x => Endpoint[X :: ... HNil] :+: empty[(Y :: ... HNil) :+: (Z :: ... HNil)]
  case y => Endpoint[Y :: ... HNil] :+: empty[(X :: ... HNil) :+: (Z :: ... HNil)]
  case z => Endpoint[Z :: ... HNil] :+: empty[(X :: ... HNil) :+: (Y :: ... HNil)]
}

But compile time keep increasing drastically from those inferances, I'll have a second look at all of that and look forward your proposition.

Other than that, everything is working fine and I thank you all for your work with Finch!
tpetillot
@tpetillot
Another quick point I would like to hear about is the implicit resolution of the encoders. I expected to have to import all the encoders when compiling the endpoint, but this was not the case. How is this possible? (Shapeless super-powers again?)
Sergey Kolbasov
@sergeykolbasov
there is additional place when you use jsonBody and co in endpoint definition
it requires you to provide an Encode instance
Or did I misunderstand your question?
Sergey Kolbasov
@sergeykolbasov

(X :: ... HNil) :+: (Y :: ... HNil) :+: (Z :: ... HNil) looks indeed nasty

can't you map it into some type T, so to fold X :: ... :: HNil into a single type first?

If you can map your hlists into a single type T such that all hlists would be mapped to T_i <: T, that would allow you to combine conditionally with ease, since you would have only an Endpoint[T] type to deal with
or are they a final composition of all endpoints? in that case you might compile them first to get a Kleisli and then conditionally pick the one you need
tpetillot
@tpetillot

Or did I misunderstand your question?

Yes, I'm referring to the encoders needed to compile an endpoint in service. I've expect to have to import somehow all X/Y/Z implicit encoders, but the resolution doesn't seems to be standart.

If you can map your hlists into a single type T such that all hlists would be mapped to T_i <: T, that would allow you to combine conditionally with ease, since you would have only an Endpoint[T] type to deal with

Thanks, I'm quit new with shapeless and still have a lot to play with so that everything is become clear.

Sergey Kolbasov
@sergeykolbasov
@tpetillot it's not really a shapeless one. There is .map available for Endpoint, and you can just pattern match the HList case a :: b :: c :: HNil
tpetillot
@tpetillot
Hi all ! Is there any document about the upgrade of twitterVersion to 21.2.0 and the implication? We would be willing to help.
Ryan Plessner
@rpless
hrm it seems like scala steward hasn't made any PRs for the latest version. It might be because finagle/finch#1306 is not merged yet, although I'm not 100% sure on that. You can in theory bump the version of finagle on your side. I'm doing that currently at work and have not encountered any issues between finagle and finch. You do still risk binary incompatibility if you are using other parts of Finagle. Finagle doesn't guarantee bincompat and in my experience does break it often, but is good about documenting those in the changelog
tpetillot
@tpetillot
thanks for your feedback, we'll try it right away!
tpetillot
@tpetillot
nothing break, looks all good. Too bad we need to fork, hope to see finagle/finch#1306 merged soon :pray:
awu
@awu
hey folks, based on this issue finchx artifacts will be getting deprecated, and the default finch artifacts will be polymorphic. any idea when that's happening?
naresh kumar
@naresh58:matrix.org
[m]
I am trying to build a post endpoint using FINCH. I am extending Endpoint.Module[IO] . I want to return Future[Output[Unit]] it runs fine. It compiles well but I see a warning in IDE saying cannot resolve overloaded method. Endpoint works as expected but just wanted to check if warning can be ignored.
Sergio Cano
@serdeliverance
Hi, everyone. I new to finagle finch and looking in the history of this channel the following question maybe sound like a repeated one: is there support for Scala 2.13?
Grigory
@pomadchin
@serdeliverance yes, there is; check out the latest release notes https://github.com/finagle/finch/releases/tag/v0.32.1
1 reply
Nicolas Rinaudo
@nrinaudo
There appears to be issues between the latest version of finch and recent versions of shapeless:
[error] /path/to/File.scala:30:41: Symbol 'type shapeless.ops.FnToProductInstances.Aux' is missing from the classpath.
[error] This symbol is required by 'value io.finch.internal.Mapper.ftp'.
[error] Make sure that type Aux is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
[error] A full rebuild may help if 'Mapper.class' was compiled against an incompatible version of shapeless.ops.FnToProductInstances
is this something that's likely to be fixed, or is finched not being maintained anymore?
Ryan Plessner
@rpless
hey @nrinaudo I've tried this out with a couple of small examples on both the old finch artifacts and the finchx artifacts and can't seem to reproduce. what versions of finch, shapeless, and scala are you using (just want to make sure I'm trying the same things as you)?

is finched not being maintained anymore?

I wouldn't say unmaintained, but definitely less active recently

Nicolas Rinaudo
@nrinaudo
Let me confirm. It's actually caused by a refined dependency, let's see if I can work out the details
so from what I can see, finchx depends on shapeless 2.3.3, and refined on 2.3.6
Nicolas Rinaudo
@nrinaudo
this seems kind of odd, I'd have assumed patch versions of shapeless to be binary compatible..
Nicolas Rinaudo
@nrinaudo

there you go, here's a minimal test case.
build file:

libraryDependencies ++= Seq(
  "com.github.finagle" %% "finchx-circe" % "0.32.1",
  "com.chuusai" %% "shapeless" % "2.3.6"
)

Main file:

import io.finch._
import cats.effect.IO

object Main extends App with Endpoint.Module[IO] {
  val hello: Endpoint[IO, String] = get("hello") { Ok("Hello, World!") }
}
output:
[error] /path/to/project/src/main/scala/Main.scala:5:55: Symbol 'type shapeless.ops.FnToProductInstances.Aux' is missing from the classpath.
[error] This symbol is required by 'value io.finch.internal.Mapper.ftp'.
[error] Make sure that type Aux is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
[error] A full rebuild may help if 'Mapper.class' was compiled against an incompatible version of shapeless.ops.FnToProductInstances.
[error]   val hello: Endpoint[IO, String] = get("hello") { Ok("Hello, World!") }
[error]                                                       ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 0 s, completed 26-May-2021 16:38:12
Ryan Plessner
@rpless
oh thanks @nrinaudo. I can repro that now, I was trying with shapeless 2.3.7 which seems to work. The release notes of 2.3.7 indicate there was an accidental breaking change in 2.3.6 that was reverted in 2.3.7 https://github.com/milessabin/shapeless/releases/tag/v2.3.7. would it be possible for you to use that version?
Nicolas Rinaudo
@nrinaudo
Probably! Thanks for working it out, that’s great
Nicolas Rinaudo
@nrinaudo
Guess I was just unlucky : there's a new version of refined being released as we speak that upgrades to the "good" version of shapeless