Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 13:21
    rossabaker commented #3768
  • 13:21
    rossabaker commented #3768
  • 10:42
    ashwinbhaskar assigned #3768
  • 03:32
    jyoo980 commented #3768
  • 03:30
    jyoo980 commented #3768
  • 03:13
    jyoo980 commented #3768
  • Oct 25 23:16
    rossabaker closed #3773
  • Oct 25 23:16
    rossabaker commented #3773
  • Oct 25 22:09
    rossabaker closed #3785
  • Oct 25 22:09
    rossabaker commented #3785
  • Oct 25 21:51
    IcyEagle opened #3785
  • Oct 25 15:03
    rossabaker commented #3766
  • Oct 25 12:20
  • Oct 25 09:24
    ashwinbhaskar commented #3766
  • Oct 25 09:24
    ashwinbhaskar commented #3766
  • Oct 25 03:37
    rossabaker labeled #3752
  • Oct 25 02:14
    ashwinbhaskar synchronize #3752
  • Oct 25 02:11
    ashwinbhaskar synchronize #3752
  • Oct 24 22:37
    domaspoliakas synchronize #3784
  • Oct 24 22:09
    domaspoliakas commented #3784
Drew Boardman
@drewboardman
IT seems like firebase is pretty nice
still havent found an example of using in development/test though
I could probably just stub the responses for those environments
Peter Storm
@peterstorm
@rossabaker Cheers again! I'll take a look at that too :)
bkunyiha
@bkunyiha
I have an app running an old version of http4s 0.15.2 and was trying to figure out how to write a EntityDecoder for CSV.
Could not find sample code for doing that
Gabriel Volpe
@gvolpe
@bkunyiha that version has been EOL'd long ago. I'd suggest taking the hard path and upgrade to the latest, don't think you'd be able to find help for such an old version.
Ross A. Baker
@rossabaker
If you don't care about streaming, you can take EntityDecoder.text.map(f), where f is a String => CSV.
If you do care about streaming, look at EntityDecoder.scala for examples using decodeBy. But that's using a stream library I haven't thought of in years, so yeah, strongly recommend Gabriel's advice if you can do it.
Colt Frederickson
@coltfred
I'm getting an issue where I'm using a blaze client, but it appears that after some period of time I get
2020-10-23T10:22:49.909-06:00    [ioapp-compute-1] DEBUG o.h.c.PoolManager - Requesting connection for https://s3.us-east-1.amazonaws.com: curAllocated=10 idleQueues.size=0 waitQueue.size=0 maxWaitQueueLimit=256 closed=false
    2020-10-23T10:22:49.910-06:00    [ioapp-compute-1] DEBUG o.h.c.PoolManager - No connections available for the desired key, https://s3.us-east-1.amazonaws.com. Adding to waitQueue: curAllocated=10 idleQueues.size=0 waitQueue.size=0 maxWaitQueueLimit=256 closed=false
After that I the waitQueue.size just goes up and up and nothing ever "works" again...
Colt Frederickson
@coltfred
I am turning the client into and httpApp and sending the response back from my http4s service.
I recall @ChristopherDavenport warning about the caller needing to consume the entire response or something not releasing properly? I'm making the requests with Postman and viewing the response so I think it's being entirely consumed.
Ross A. Baker
@rossabaker
You're making requests with postman with blaze-client?
Colt Frederickson
@coltfred
@rossabaker Well, I'm taking requests from postman, translating them to a new url and forwarding the body on to that url. It then turns the client (which is making the modified request) back into an app with .toHttpApp and sending the response it gets to the caller.
@rossabaker Kinda like a proxy, but with some other things mixed in
If I change to the async-http-client for jdk 11, I do not have any issues.
Ross A. Baker
@rossabaker
We've had client deadlocks before, so this is not unprecedented. But I'm not aware of any now.
A reproducible example would help a lot in chasing this one down, unless you're happy with one of these other backends.
Tomas Klubal
@blondacz
Hello, I'd like to implement authentication and authorization using JWT for our web server that is using http4s. As we would like to have declarative authorization and we don't need to have access to user details at the routes, I'd like to implement it as a middleware only. Is this possible? How would I go about it? Thx
Michal Lacko
@visox
hi all any nice example of http4s with dotty, if it exists ?
Ross A. Baker
@rossabaker
@blondacz I think tsec may have some JWT functionality, but even if that's not the right shape, what you want to do is possible. If your JWT implementation wants to pass along an request with user details, and your service doesn't need it, you can expand that service into something that discards the user details. Are you familiar with Kleisli.local? That changes the input shape.
@visox There is an active project to compile http4s on Dotty. I've heard rumors of it working today in compat mode. My guess is that the interpolators (e.g., uri"http://www.example.com/") will fail at compile time, that any derived JSON codecs you use are likely to fail, and other things are likely to work.
Michal Lacko
@visox
hmm kk thx @rossabaker
Ross A. Baker
@rossabaker
I'd love an experience report on that if you try it. We're working hard on compiling it, but it's a big lift, because some of our internal dependencies don't work on Dotty.
Here's the effort, if you want to follow along. :smile:
Paul Snively
@paul-snively
tsec even has an http4s module.
Tomas Klubal
@blondacz
@paul-snively Unfortunatelly I don't think it supports JWKS, which is mandatory for us.
Paul Snively
@paul-snively
I see. But my bet is, that module demonstrates how to implement what you need.
rnd4222
@rnd4222_gitlab
We are using custom middleware using java libraries for jwt. No issues so far
David Zhu
@noblecraft

hi not sure if this is a fs2 question or a http4s question:
I’ve got an async api that returns a Stream of Rows :

def data(id: Int): Stream[F, Row] = {
    for {
      q <- Stream.eval(Queue.noneTerminated[F, Row])
      _ <- Stream.eval { Concurrent[F].delay {
          someApi.asyncData(id,  new AsyncDataHandler {
            override def onRow(r: Row): Unit = q.enqueue1(Some(r))
            override def onEnd(): Unit = q.enqueue1(None)
          })
        }
      }
      r <- q.dequeue
    } yield r
}

in http4s, i have:

    val rowsEndpoint = HttpRoutes.of[IO] {
      case GET -> Root / “data" / IntVar(id) => {
        Ok(data(id).map(r =>
          s""”{"col1": ${r.col1()}}"""
        ))
      }
    }

i don’t seem to be getting anything back from the http4s server when hitting the endpoint
i’ve debugged, and the onRow() and onEnd() are being hit
however it seems maybe the Stream never terminates???

Fabio Labella
@SystemFw
@noblecraft you need to unsafeRun the enqueues
David Zhu
@noblecraft
@SystemFw how would i unsafeRun?
i’m struggling to find the right implicit import ?
do i ConcurrentEffect[F].runAsync()().unsafeRunSync?
Fabio Labella
@SystemFw
yes
or .toIO.unsafeRunSync
still needs a ConcurrentEffect
David Zhu
@noblecraft
ok thanks @SystemFw
Andrii
@abramov_andrii_twitter

Hello everyone!
I am pretty new to http4s.

Could you clarify a bit this moment:
I would like to maintain a shared connection pool to http resource.
Docs (https://http4s.org/v0.20/client/) say that we should close BlazeClientBuilder[IO](global) but there are no "shutdown" methods in Resource trait.

Am I right that every statement BlazeClientBuilder[IO](executionContext).resource.use { client => ... } creates a new connection pool?
Is it better to extract BlazeClientBuilder[IO](executionContext).resource as an instance variable and use it as the following:

val httpClient = BlazeClientBuilder[IO](executionContext).resource
def a = httpClient.use.expect[String]("http://localhost:8080/a")
def b = httpClient.use.expect[String]("http://localhost:8080/b")

?

nigredo-tori
@nigredo-tori
@abramov_andrii_twitter , the idiom is to wrap most of your program in one .use, and thread the Client[IO] through the rest your code.
nigredo-tori
@nigredo-tori
Like here, where getSite is the rest of your program.
Fabio Labella
@SystemFw

@abramov_andrii_twitter

but there are no "shutdown" methods in Resource trait.

Resource takes care of closing automatically, each time you call use( r => yourIO), it will open r and close it once yourIO is done. Therefore, like @nigredo-tori says, you need to call use once, and thread the client through

as an instance variable and use it as the following:

ah, this is really important. In purely functional programming, making things into instance variables does not change the behaviour (because there are no side-effects), the evaluation of effects is instead controlled through explicit methods, in this case use

// opens two pools
def a = client.resource.use(...)
def b = client.resource.use(...)
a >> b
// also opens two pools
val c = client.resource
def a = c.use(...)
def b = c.use(...)
a >> b
// opens one pool and shares it
client.resource.use { c =>
  a(c) >> b(c)
// also opens one pool and shares it
val c = client.resource
c.use { c =>
  a(c) >> b(c)
}

```

Andrii
@abramov_andrii_twitter
Got it, thank you very much for explanation.
Does it mean that we open a new connection to http server each time we call it?
For heavily load service (I mean on the client side) it is not so practical, am I right?
Fabio Labella
@SystemFw
it's better to share the pool, yes (the first two examples)
the practical consequence is that each place that needs to make calls needs to take a Client as an argument
Luís Campos
@LLCampos
Is there any http4s middleware out there that does per-endpoint metrics?
rnd4222
@rnd4222_gitlab
The issue is, middlewares are working on HttpRoute level, where any information about endpoints is lost
Erlend Hamnaberg
@hamnis
there is a classifier function which accepts the request, there you can add some more infomation, i.e the path
alexh2o17
@alexh2o17_gitlab
Hi, I'm using parseStreamedFile for decode Multipart in my http4s deployed on a pod openshift. After memory limit my pod go down. Seems that htt4s maintain file all in memory also with MultipartPaser.parseStreamedFile
this is my code
req.body.through(MultipartParser.parseStreamedFile[UserTask](Boundary(boundary),
                blocker)).compile.last.flatMap(........)