Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 21:43
    scala-steward closed #1376
  • 21:43
    scala-steward commented #1376
  • 21:43
    scala-steward opened #1412
  • Sep 16 22:29
    scala-steward closed #1405
  • Sep 16 22:29
    scala-steward commented #1405
  • Sep 16 22:29
    scala-steward opened #1411
  • Sep 16 11:19
    scala-steward closed #1387
  • Sep 16 11:19
    scala-steward commented #1387
  • Sep 16 11:19
    scala-steward opened #1410
  • Sep 14 20:51
    scala-steward closed #1386
  • Sep 14 20:51
    scala-steward commented #1386
  • Sep 14 20:51
    scala-steward opened #1409
  • Sep 14 19:22
    sergeykolbasov synchronize #1407
  • Sep 14 19:22

    sergeykolbasov on scala-3

    Rewrite core with Scala 3 Use github actions for tests (compare)

  • Sep 14 18:21
    sergeykolbasov commented #1407
  • Sep 14 18:20

    sergeykolbasov on master

    Use GitHub actions for builds (… (compare)

  • Sep 14 18:20
    sergeykolbasov closed #1408
  • Sep 14 18:15
    sergeykolbasov opened #1408
  • Sep 14 18:14

    sergeykolbasov on gh-actions

    Use GitHub actions for builds (compare)

  • Sep 14 18:11
    sergeykolbasov synchronize #1407
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
Kris
@lambdakris

Hi, I'm new to things like Finch and Cats Effect and trying a few experiments. I tried to adapt the https://github.com/finagle/finch#hello-world example using scala 3 and I am getting an encoder error.

My build.stb looks like

val scala3Version = "3.0.2"

lazy val root = project
  .in(file("."))
  .settings(
    name := "scala3-simple",
    version := "0.1.0",

    scalaVersion := scala3Version,

    libraryDependencies ++= Seq( 
        "com.github.finagle" % "finchx-core_2.13" % "0.32.1",
        "com.github.finagle" % "finchx-circe_2.13" % "0.32.1",
        "io.circe" % "circe-generic_2.13" % "0.14.1"
    )
  )

My Main.scala looks like

import cats.effect.IO
import io.finch._
import com.twitter.finagle.Http
import com.twitter.util.Await

object Main extends App with Endpoint.Module[IO] {
  val api: Endpoint[IO, String] = get("hello") { 
    Ok("hello") 
  }

  Await.ready(Http.server.serve(":8080", api.toServiceAs[Text.Plain]))
}

When I try to sbt run, I get the following error message:

[error] -- Error: C:\Users\Kris.garcia\Code\open\birdir\src\main\scala\Main.scala:11:68
[error] 11 |  Await.ready(Http.server.serve(":8080", api.toServiceAs[Text.Plain]))
[error]    |                                                                    ^
[error]    |An Endpoint you're trying to convert into a Finagle service is missing one or more encoders.
[error]    |
[error]    |  Make sure A is one of the following:
[error]    |
[error]    |  * A com.twitter.finagle.http.Response
[error]    |  * A value of a type with an io.finch.Encode instance (with the corresponding content-type)
[error]    |  * A coproduct made up of some combination of the above
[error]    |
[error]    |  See https://github.com/finagle/finch/blob/master/docs/src/main/tut/cookbook.md#fixing-the-toservice-compile-error
[error]    |.
[error]    |I found:
[error]    |
[error]    |    io.finch.ToResponse.valueToResponse[cats.effect.IO, String,
[error]    |      ("text/plain" : String)
[error]    |    ](cats.effect.IO.ioEffect, io.finch.Encode.encodeStringAsTextPlain,
[error]    |      shapeless.Witness.apply[T]
[error]    |    )
[error]    |
[error]    |But method apply in object Witness does not match type shapeless.Witness.Aux[("text/plain" : String)].
[error]    |
[error]    |One of the following imports might make progress towards fixing the problem:
[error]    |
[error]    |  import shapeless.~?>.idKeyWitness
[error]    |  import shapeless.~?>.idValueWitness
[error]    |  import shapeless.~?>.witness
[error]    |
[error] one error found
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 9 s, completed Sep 11, 2021, 4:39:25 PM

Now, I did try adding the different shapeless imports as suggested, but unfortunately the error itself was not resolved.

Could anybody offer some insight or suggestions?

Sergey Kolbasov
@sergeykolbasov
shapeless literal types (witness) don't play well with Scala 3, sadly
Kris
@lambdakris
OOoohh, that makes sense, thanks @sergeykolbasov!