-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IOLocal to Local Access for Middlewares #195
Comments
There is an idea to simplify propagation in a way passing |
I can't remember why I pulled There's talk on #182 1 about how best to provide access to the local vault. It didn't really come up until people started exercising propagators. We could provide some sort of temp package with whatever gets settled on? API is going to need to be rethought if that CE ticket fails. I still believe in that CE3 ticket: things get real weird using IOLocal statefully through arbitrary libraries. Footnotes
|
Is this something that we could do for now? Be good to not have to copy paste this Local instance around. Or is it fine to just use kleisli? I'm not really sure when to use one over the other. |
I see no reason not to provide the instance. The choice between that or Kleisli is really a matter of taste. Kleisli tends to intimidate people, but shouldn't. Much like IO is a fancy way to build your program as a Function0, Kleisli is a fancy way to build your program as a Function1. There's no hidden fiber state. It's right there in the types. The problem is, it's right there in the types. That Vault is in your face unless you are rigorous about being final tagless. (I am, but I'm old and unfashionable.). And your main method probably involves some type tetris. Tagless or not, I generally recommend IOLocal. It does weird shit if you use non-Local methods, but properly constrained, it works well with low cognitive overhead. |
|
That performance claim is true, easily demonstrable in contrived benchmarks, and doesn't tend to be meaningful as soon as the return type is RealIO[BloatedBusinessResponse]. |
@rossabaker I'm a big fan of tagless final, at $work we will be adopting this as we move away from Akka. Just thought it might be nice for you to hear that there are people still advocating for it!
Cool - thanks, I'll try and raise a PR some point soon.
OK thats good to hear, personally I like having that context reflected in my effect type.
I was under this impression too, at $work we mostly write microservices that call other microservices/read DBs so I don't see that performance penalty having any meaningful impact on us |
End systems seem to require access to the
Local[F, Vault]
orIOLocal[Vault]
to be able to leverage the TextMapPropagators. However currently the[A] =>> IOLocal[A] => F[_] =>> Local[F,A]
is private which means any middleware that operates using the expected Local semantics has to request the end user application to do this transformation for them.I know the desire is to upstream this to cats-effect, however it seems to me that anyone leveraging the java backend for propagators will need this transformation available or write the same boilerplate themselves into their end user application.
https://github.com/ChristopherDavenport/natchez-http4s-otel/blob/otel2/examples/src/main/scala/example/Http4sExample.scala#L41-L64
The text was updated successfully, but these errors were encountered: