Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 04 08:00
    scala-steward closed #1421
  • Dec 04 08:00
    scala-steward commented #1421
  • Dec 04 08:00
    scala-steward opened #1425
  • Nov 30 07:41
    scala-steward closed #1401
  • Nov 30 07:41
    scala-steward commented #1401
  • Nov 30 07:41
    scala-steward opened #1424
  • Nov 28 05:39
    scala-steward closed #1373
  • Nov 28 05:39
    scala-steward commented #1373
  • Nov 28 05:39
    scala-steward opened #1423
  • Nov 26 15:33
    scala-steward closed #1420
  • Nov 26 15:33
    scala-steward commented #1420
  • Nov 26 15:33
    scala-steward opened #1422
  • Nov 23 16:27
    rpless commented #1417
  • Nov 23 14:35
    mfirry commented #1417
  • Nov 23 14:15
    SethTisue commented #1417
  • Nov 23 13:53
    rpless commented #1417
  • Nov 22 23:48
    SethTisue commented #1417
  • Nov 22 23:47
    SethTisue commented #1417
  • Nov 19 07:39
    scala-steward closed #1398
  • Nov 19 07:39
    scala-steward commented #1398
Pierre Ricadat
@ghostdogpr
and zio-interop-cats is using some stuff from 2.0.0 that is not in 1.4.0
Dermot Haughey
@hderms
ah that makes sense
my knowledge of SBT is very limited
Vinh Vu
@Vinh-Vu-ck
Hey all! I am currently using the multipart fileupload, however, I’ve run into some issues where large files aren’t uploadable if the server doesn’t have enough memory/disk space to serve the request. Is there anyway I can stream the file contents?
Vladimir Kostyukov
@vkostyukov
@Vinh-Vu-ck You can surely do generic byte-level streaming but there is no really a support to parse that stream as a multipart message. Do you control your client? Can you change that as in “dowgrade to a regular byte-streaming” as opposed to multipart file upload?
Vinh Vu
@Vinh-Vu-ck
Yes, I control my client
An option we are considering is sticking with the multipart file upload, but we have been receiving 413 Request Entity Too Large for files above 100MB. We tried using .withMaxRequestSize(StorageUnit.fromGigabytes(1L)), but then our endpoint returns 404 instead. Without the .withMaxRequestSize call, we get a 413. Is this expected? Anything I’m missing?
Vladimir Kostyukov
@vkostyukov
@Vinh-Vu-ck That doesn’t sound right, especially the 404 part. The default limit is 5mb and I belive it’s bypassed when the payload is streamed. I remember it was changed recently in Finagle too. Let me look around a bit.
Vladimir Kostyukov
@vkostyukov
This is the change I was refering to: twitter/finagle#781
This still doesn’t not explain 404 you’ve been seeing. If there any other proxy sitting in fron of Finch server in your setup?
Vinh Vu
@Vinh-Vu-ck
There is no proxy sitting in front of Finch
pra527vin
@pra527vin
Is there way to log request coming in finch?
Ryan Plessner
@rpless
hi @pra527vin. It depends on whether you are using the finchx or finch artifacts. If you are using the finchx builds there is an example in the middleware example app https://github.com/finagle/finch/blob/master/examples/src/main/scala/io/finch/middleware/Main.scala#L39-L43. if you are using the finch builds you can use a finagle filter https://twitter.github.io/finagle/guide/ServicesAndFilters.html
Dermot Haughey
@hderms
not to be pessimistic but given how long it's taken finagle to support 2.13, I'm wondering what it will be like when Scala 3 finally drops. No blame towards finagle, given it's a part of a huge ecosystem and it's not a trivial effort
Sergey Kolbasov
@sergeykolbasov
not to mention things like Spark :eyes:
Sergey Kolbasov
@sergeykolbasov
well, there will be quite an earth shake in the whole Scala ecosystem for a while, but it's fiiine
Georgi Krastev
@joroKr21
well there is something to be said about companies being slow to update
e.g. Twitter doesn't care much about 2.13 so the Finagle update is a community effort
Hamdi Allam
@hamdiallam
I wouldn't say this is true. There's a lot that goes into an update. (performance regressions / breaking changes in the language). It's an effort to do at scale
Georgi Krastev
@joroKr21
Yeah and it brings little business value
So most companies don't care much and it's fine to admit it
pacman899
@pacman899

Hey, Im updating my company code to use the finchx versions (adding the F[_]). we have these -

FuturePool.unboundedPool { ....endpoint logic  }

in all our endpoints. should this be replaced with something else? or can I just delete this?

pacman899
@pacman899
not sure if something similar to FuturePool that works with cats.effect.ContextShift is needed 🤔?
pacman899
@pacman899
Im almost sure I can just delete the FuturePool and get the same logic for "free" from the F[_] change
Ryan Plessner
@rpless
@pacman899 yep! A context shift is what you want there. you could also shift on to an ExecutionContext if you are using those currently
Dermot Haughey
@hderms
@hamdiallam agreed. based on having been following the 2.13 stuff in finagle, it was quite easy to introduce performance regressions
Bagus Jatikusuma
@BagusJatikusuma
hello everyone. i have a question regarding iteratee example in finch github repo. when i tried to compile it, compiler complained that it couldnt find implicit value for parameter io.finch.LiftReader when using jsonBodyStream. should i provide LiftReader as implicit val manually? or am i missing some imports?? anyway sorry for any grammar mistakes. english isnt my native language. i hope you'll understand my question.
Sergey Kolbasov
@sergeykolbasov

Hi @BagusJatikusuma

That's interesting. Try to add import io.finch.iteratee._, it contains a missing implicit LiftReader

Bagus Jatikusuma
@BagusJatikusuma
thanks for answering @sergeykolbasov . i've done that before (i didn't change imports of the example file) but its still give me same error message. i'm using scala 2.12.10 and finchx-core, finch(iteratee and circe) version 0.31.0.
Sergey Kolbasov
@sergeykolbasov
What effect type are you using?
Bagus Jatikusuma
@BagusJatikusuma
im using cats-effect and ZIO. but both didnot work.
Bagus Jatikusuma
@BagusJatikusuma
as additional information, i didnot add any scalac configuration to build sbt. im still new to scala with its ecosystem.
Bagus Jatikusuma
@BagusJatikusuma
is it different when using finch-iteratee and finchx-iteratee?? in finch-iteratee implicit def enumeratorLiftReader() doesn't exist, but in finchx-iteratee it does.
Bagus Jatikusuma
@BagusJatikusuma
ah finally its solved. it was my mistake that i added some finch-module dependencies, not finchx-module(only finchx-core which i added xD). it was stupid mistake.
thanks @sergeykolbasov for your answer before.
Sergey Kolbasov
@sergeykolbasov
I'd say it's confusing for new comers and I hope we'll soon drop the finchx name and replace finch artefact with this one
Sergey Kolbasov
@sergeykolbasov

Hey everyone

0.32.1 is available for download, shipped for Scala 2.13 with the latest Finagle 20.3.0 and cats 2

yay
Bagus Jatikusuma
@BagusJatikusuma
congrats, great job for finagle/finch team and community
Georgi Krastev
@joroKr21
:tada:
Dino Fancellu
@fancellu

Are there any examples out there of Finch returning images, i.e. the best way? I see an example of Serving static content, but readAll doesn't exist. Any fully fleshed examples?

Thanks

For example, I tried this, and I get a partial image.
  val catpath = Paths.get(ClassLoader.getSystemResource("./cats.jpg").toURI)
  val reader = Reader.fromFile(catpath.toFile)

  val cat: Future[Buf] =Reader.readAllItems(reader).map(_.head)

  val image: Endpoint[IO, Buf] = get(imageadmin :: path[Int]) { id: Int =>
    cat.map(Ok)
  }
Dino Fancellu
@fancellu
Ah, I reckon my .head was chopping it off. Anyway, this works, I get the full cat picture back. But no doubt there are better ways
  val catpath = Paths.get(ClassLoader.getSystemResource("./cats.jpg").toURI)
  val bytes: Array[Byte] =Files.readAllBytes(catpath)
  val catbuff: Buf =ByteArray(bytes:_*)

  val image: Endpoint[IO, Buf] = get(imageadmin :: path[Int]) { id: Int =>
    Ok(catbuff)
  }.handle(exceptionToBadRequest)
Georgi Krastev
@joroKr21
I wonder if it's possible to combine finch and fs2-io for that. But I have no time to try it.
Dino Fancellu
@fancellu

I'm trying to return a 404 with a phrase that is not simple "Not Found"

This doesn't change the phrase

Output.failure(new Exception("Image not found"), Status.NotFound)

or

NotFound(new Exception("Image not found")

I get a 404 just fine. But I want the phrase to be as in the exception. Raw header is

HTTP/1.1 404 Not Found\r\nDate: Mon, 30 Mar 2020 11:51:40 GMT\r\nServer: Finch\r\nContent-Length: 0\r\n\r\n

Frederick Cai
@zhenwenc

@fancellu Me again 😄 You need to implement your own implicit Encoder[Exception], and ensure it is in scope when calling toService / toServiceAs on your endpoint(s)

See https://finagle.github.io/finch/cookbook.html#converting-errors-into-json

Dino Fancellu
@fancellu

I do

  implicit val encodeException: Encoder[Exception] = Encoder.instance(e =>
    Json.obj("exception" -> Json.fromString(e.getMessage)))

What would I need to do to get it to put the getMessage into the HTTP reason?

Currently it says

HTTP/1.1 404 Not Found

htch
@htch

Why does returning twitter's Future from endpoint with Endpoint[IO,?] type works? Using finchx 0.32.1

For example:

import cats.effect.IO
import com.eslgaming.services.platform.lokalisewebhook.domain.{Event, WebhookError}
import com.eslgaming.services.platform.lokalisewebhook.handler.WebhookEventHandler
import com.twitter.util.Future
import com.twitter.util.logging.Logging
import io.finch.{Endpoint, Output, Ok, NoContent}
//import io.finch.catsEffect._
import io.finch.circe._
import shapeless.HNil
import io.circe.Json
//import io.catbird.util.twitterFutureInstance

object LokaliseWebhookEndpoint extends Logging {

  def apply(ipRangeEndpoint: Endpoint[IO,HNil], webhookEventHandler: WebhookEventHandler): Endpoint[IO,Unit] =
    Endpoint[IO].post(Endpoint[IO].path("webhook") :: ipRangeEndpoint :: Endpoint[IO].jsonBody[Json]) { body: Json =>
      if (body == Json.arr(Json.fromString("ping"))) {
        Future.value(Ok(()))
      } else {
        val event = body.as[Event].getOrElse(throw new RuntimeException())
        webhookEventHandler.handleEvent(event) map {
          case Right(_) => NoContent[Unit]
          case Left(err) => {
            Output.failure(new RuntimeException(err.message), err.status)
          }
        }
      }
    }

}

webhookEventHandler.handleEvent returns a twitter Future

Sergey Kolbasov
@sergeykolbasov
@htch there is an implicit coversion of Twitter Future -> Anything with Async
it lives inside of ToAsync and is available only for method endpoints, such as get("foo") { ... }
Kenneth Monteiro
@ManiacViper
Hello