Actor model on top of cats? #2627
-
Hi there - I might be missing something (seriously - I am frantically catching up), but an Actor model on top of Cats Effects seems like a no-brainer to me, but there doesn't seem to be one. How do you manage long running, independant, but identifiable processes? A process per session on a web server for example, or a process per long running async something or other. I'd assume Fiber, but:
As I say, this Q is firstly "why is an actor model on top of cats a bad idea" and maybe secondly "what do people do instead" :-) |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 10 replies
-
I arrived to CE3 from Akka world, so I also had a hard time wrapping my head around this one at first :) still do sometimes!
Yes, fibers are indeed the answer. They are lightweight and generally awesome!
It is fairly straightforward to make an "actor" using fs2's trait Channel[F[_], A] {
def send(a: A): F[Either[Channel.Closed, Unit]]
def stream: Stream[F, A]
} https://github.com/typelevel/fs2/blob/main/core/shared/src/main/scala/fs2/concurrent/Channel.scala The
As for why this pattern is not so popular, I think it just doesn't lend itself well to the FP paradigm :) consider the example of web server, for example. http4s models this concept as a function Anyway just my 2 cents, maybe someone smarter can give us both some real insight on the matter 😆 |
Beta Was this translation helpful? Give feedback.
-
this was too on-point :-) https://twitter.com/buitengebieden_/status/1467439671865229314 |
Beta Was this translation helpful? Give feedback.
-
Perhaps you should talk to @alcestes on the topic of Actors and cats effects. I put together a Twitter thread earlier this year on some of his talks and pointers to his work https://twitter.com/bblfish/status/1358392715118010369 |
Beta Was this translation helpful? Give feedback.
-
It would be useful to put together a list of use cases where actors are very useful and cannot be so easily done without.
|
Beta Was this translation helpful? Give feedback.
This comment was marked as spam.
This comment was marked as spam.
-
If you are still looking for actors, I put together a small gists using CE3, Ref, Deferred, magic. https://gist.github.com/Swoorup/1ac9b69e0c0f1c0925d1397a94b0a762 |
Beta Was this translation helpful? Give feedback.
I arrived to CE3 from Akka world, so I also had a hard time wrapping my head around this one at first :) still do sometimes!
Yes, fibers are indeed the answer. They are lightweight and generally awesome!
It is fairly straightforward to make an "actor" using fs2's
Channel
API.https://github.com/typelevel/fs2/blob/main/core/shared/src/main/scala/f…