Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 20 22:49
    codecov-io commented #1162
  • Sep 20 22:37
    scala-steward opened #1162
  • Sep 20 16:19
    rpless commented #1161
  • Sep 20 15:03
    dkulichkin edited #1161
  • Sep 20 15:02
    dkulichkin edited #1161
  • Sep 20 15:01
    dkulichkin opened #1161
  • Sep 20 05:51
    codecov-io commented #1160
  • Sep 20 05:40
    scala-steward opened #1160
  • Sep 19 08:57

    sergeykolbasov on mapk

    (compare)

  • Sep 19 08:57

    sergeykolbasov on master

    Add Endpoint.mapK (#1158) (compare)

  • Sep 19 08:57
    sergeykolbasov closed #1158
  • Sep 18 23:19
    rpless commented #1147
  • Sep 18 22:28
    codecov-io commented #1159
  • Sep 18 22:17
    scala-steward opened #1159
  • Sep 18 16:10
    vkostyukov commented #1147
  • Sep 18 12:25
    codecov-io commented #1158
  • Sep 18 12:25
    codecov-io commented #1158
  • Sep 18 12:14
    sergeykolbasov opened #1158
  • Sep 18 12:14
    sergeykolbasov review_requested #1158
  • Sep 18 12:13

    sergeykolbasov on mapk

    Add Endpoint.mapK (compare)

Vladimir Kostyukov
@vkostyukov
@zhangzhonglai Hey, have you figured out your stuff yet? Ping me if you need any help.
@JanBessai Sorry I’m probably late to the party, but I’m curious why you want to expose Resource. We use it internally in a couple of places, but it’s always hidden from they users behind a IO.
zhangzhonglai
@zhangzhonglai

@vkostyukov

Not yet for now.

I tried to replace the following code (which in class 'EncodeEnumerator' of finchx-iteratee package)

    final def apply(cb: Either[Throwable, Unit]): IO[Unit] = IO.unit

to

    final def apply(cb: Either[Throwable, Unit]): IO[Unit] = cb match {
      case Right(_)    => IO.unit
      case Left(error) => IO.raiseError(error)
    }

After that, the program can throw the exception, but it still can't handle the Exception.
I'm not very familiar with the cats.IO.
If you can give me some hints, I would very appreciate for your.

Jan Bessai
@JanBessai
@vkostyukov thanks for your reply! You are not too late, I decided to work on other stuff first. I'm implementing a server to host jgit instances populated with generated files. The resource is a git repository which is stored on the server's disk, has state and is created/destroyed when the server starts/shuts down. From how I understood the documentation resource seems appropriate for that rather than just IO
Vladimir Kostyukov
@vkostyukov
@zhangzhonglai I think the key problem here is that the it’s probably too late to respond with 400 when the stream fails. We’re already passed the point of sending headers back (and the response status) to the client. I’d imagine you can still do something along those lines by returning IO.raiseError instead.
@JanBessai Yes, you’re on point about this. Have you seen Endpoint.fromInputStream? It operates on Resource and, I belive, should suite your needs well.
zhangzhonglai
@zhangzhonglai
@vkostyukov yes, maybe you're right. Actually I don’t quite understand the whole process in the Finch and IO context. I need to read the codes deeply and try to raise or throw the error before response the headers. Really thank you for the hints.
tigerwings
@tigerwings
Hi all, a newbie question: how to bind a trait to Endpoint? I want something as the following
  sealed trait Message
  case class GoodMessage(goodMessage: String)
  case class BadMessage(badMessage: String)

  def hello: Endpoint[IO, Message] = get("hello" ) {
    Ok(GoodMessage("good"))
  }
Sergey Kolbasov
@sergeykolbasov
@tigerwings if I remember correctly, Endpoint is invariant (because of invariant F[_]) but Output is covariant. Try to explicitly set the type:
Ok(GoodMessage("good")): Output[Message]
//or
Ok(GoodMessage("good") : Message)
Phill101
@Phill101
// or
Ok[Message](GoodMessage("good"))
tigerwings
@tigerwings
@sergeykolbasov and @Phill101 , thank you.
Octav Zaharia
@octavz
hey, is there any ZIO + finch somewhere?
Dermot Haughey
@hderms
I believe you could write a ToAsync instance to allow finchx endpoints to work with ZIO
Octav Zaharia
@octavz
there is an Effect instance in cats interop i used that , it seems it compiles
Vladimir Kostyukov
@vkostyukov
It should work fine if there is Effect instance for ZIO (I assume there is).
Phill101
@Phill101

@octavz hi. I research for a zio and finch compatibility.
I'll share results soon. You should pay attention to finagle/finch#1138
Fix for this issues is not in 0.3.0 I guess.
You should know that it's extremely painful to deal with Endpoint's in ZIO style, cause it parametrized with invariant F (because cats effect). So you should explicitly define types everywhere.
My typical endpoint now looks like:

class Todo[R <: TodoRepository] extends EndpointModule[TaskR[R, ?]] {
  type TodoTask[A] = TaskR[R, A]
  def getAll: Endpoint[TodoTask, List[TodoItem]] = get("todos") {
    val task: TodoTask[List[TodoItem]] = TodoService.getAll
    task.map(Ok)
    // or
    // TodoService.getAll.map(Ok): TodoTask[Output[List[TodoItem]]
  }
}

I looking for a better solution. Let me know if you find it

Octav Zaharia
@octavz
ty @Phill101
indeed it seems it is in master, but not yet released
can i get a nightly build from somewhere ?
Phill101
@Phill101
publishLocal :D
Vladimir Kostyukov
@vkostyukov
@octavz I’m going to cut a 0.31 release now. Should be in Maven Central in about an hour or so.
Octav Zaharia
@octavz
ty!
Vladimir Kostyukov
@vkostyukov
Just released normal finch-* artifacts for 0.31.
These are against Finagle 19.8.
Vladimir Kostyukov
@vkostyukov
Anything stops us from jumping onto Cats 2.0 and Cats-Effect 2.0?
Ryan Plessner
@rpless
@vkostyukov I think we should give it a try. Based on Travis' blog about migrating seems like the only real pain was with Parallel which I don't think we use
and effect seems to have maintained binary compatibility with 1.x
Sergey Kolbasov
@sergeykolbasov
yay, there is finagle release 19.9.0 for 2.13
not for finagle-http though :(
Vladimir Kostyukov
@vkostyukov
I think it should happen in October release
s/think/hope
Dermot Haughey
@hderms
I'm excited
Vladimir Kostyukov
@vkostyukov
Seems like we already have PRs updating fs2, cats, cats-effect already to 2.0 and they are all green. Do we merge them now or wait for Scala 2.13 support and do a mega release later?
Sergey Kolbasov
@sergeykolbasov
I don't mind either
It's unlikely we're going to release next finch until 19.10 which hopefully will support 2.13
Dermot Haughey
@hderms
I suppose I should look at what finagle components I can try upgrading to 2.13
bifunctor
@bifunctor
So the finch supports scala 2.13?
Vladimir Kostyukov
@vkostyukov
@bifunctor Not yet, waiting for finagle-http on 2.13.
Kenneth Monteiro
@ManiacViper
Hi guys anyone can help with finch bad request error messages
ive got finch error encoding setup
implicit val encodeExceptionCirce: Encoder[Exception] = Encoder.instance {
    case e: Error => errorToJson(e)
    case Errors(nel) => Json.arr(nel.toList.map(errorToJson): _*)
  }
  def errorToJson(e: Error): Json = ErrorResponse(Option(e.getMessage).getOrElse("No error message available")).asJson

  final case class ErrorResponse(message: String)
but I can't seem to see it in the response.contentString, the value is ""
A bad request is returned in the status code but no message in the contentString
Set it up, similar to docs example http://finagle.github.io/finch/cookbook.html#converting-errors-into-json but I dont handle types of errors, should not make a difference though
Kenneth Monteiro
@ManiacViper
Never mind! I didnt import the encoder ! my bad
Georgi Krastev
@joroKr21
Hi, I have a somewhat weird question. If I have an Endpoint[IO, A] and an Endpoint[Task, A], is it possible to combine them into the same Service?
Sergey Kolbasov
@sergeykolbasov

Hey

You'd need to implement mapK for Endpoint I think

and use some FunctionK to convert F ~> G
Sergey Kolbasov
@sergeykolbasov
shouldn't be too hard:
  final def mapK[G[_]](self: Endpoint[F, A])(nat: FunctionK[F, G]): Endpoint[G, A] =
    new Endpoint[G, A] {
      final def apply(input: Input): Endpoint.Result[G, A] = self(input) match {
        case EndpointResult.Matched(rem, trc, out) =>
          EndpointResult.Matched(rem, trc, nat(out))
        case skipped: EndpointResult.NotMatched[F] => skipped.asInstanceOf[EndpointResult[G, A]] //should be safe to do, there are no effects on skipped results
      }

      override def item = self.item
      final override def toString: String = self.toString
    }
Georgi Krastev
@joroKr21
Cool thanks! Maybe worth adding this to Endpoint
Sergey Kolbasov
@sergeykolbasov
yep, there was a ticket for it I think