Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Oleg Pyzhcov
@oleg-py
well there's nothing stopping you; but I thought the whole point of AS was also to hide actors away, and in FP communities the general advice is to never use actors :D
Rohan Sircar
@rohan-sircar
You can use observables with actors, it just won't be "pure"
Unless you have... fp actors that take IO in their message handlers
lekan
@horlahlekhon
well, the question of purity is something else. but i get, if you want to get impure just use the akka, but crossing borders to PureFP libraries, one should ideally move away from things like actors.
Darren Bishop
@DarrenBishop
I think if you want to have fun with Akka (Actors), have at it; but genuinely feel that, if done right, there’s little value in mixing in another concurrency abstraction (i.e. MO) or going over trodden streaming ground (i.e. AS)
Are you migrating a legacy Akka Actor application?
lekan
@horlahlekhon
No, am about to start a fun project and looking to try something new, i know AS and actors to some extent. so i was looking at the possibilities of using Monix or other RX implementations, plus i have used Tasks a bit and it was cool. so am looking at doing the whole thing using Monix Observables and Tasks. but i will be needing actors for managing events; which is why i was curious if i can use this with actors.
Rohan Sircar
@rohan-sircar
Actors are good at state machines and supervision heirarchies. You can also build state machines with observables though but you don't get supervision.
Darren Bishop
@DarrenBishop
MO is awesome and the guys here are brilliant in their support, so would defo encourage you to give it a shot
Rohan Sircar
@rohan-sircar
I have a game project where the program is in Task and the game entities are modelled as actor state machines if you want to take a look. I have an example of building an observable from an actors state safely though i'm not sure if i uploaded it.
lekan
@horlahlekhon

I have a game project where the program is in Task and the game entities are modelled as actor state machines if you want to take a look. I have an example of building an observable from an actors state safely though i'm not sure if i uploaded it.

That will be cool to look at, thanks

Darren Bishop
@DarrenBishop
2nd @rohan-sircar; actors are good for state and responsibility capture and (de)composition; along with supervision it’s pretty powerful

i will be needing actors for managing events

I am curious what you mean by this?

lekan
@horlahlekhon

MO is awesome and the guys here are brilliant in their support, so would defo encourage you to give it a shot

I will, at least until i hit a roadblock. when one has been ingrained in thinking the actor way, it can be sometime daunting to implement the same things using other ways.

Rohan Sircar
@rohan-sircar
Actors have their place i feel. They are complementary to observables.
Darren Bishop
@DarrenBishop

I have an example of building an observable from an actors state

@rohan-sicar (sorry) was that using Var?

lekan
@horlahlekhon

i will be needing actors for managing events

I am curious what you mean by this?

i want to be able to send messages and encapsulate all operations that fulfils the message in a single entity like actors did and also have that heirarchies where one entity can manage another.

Rohan Sircar
@rohan-sircar
Now the akka implementation is impure but that's not necessary. See zio-actors for an RT implementation.
@DarrenBishop no, i used an asyncqueue
Rohan Sircar
@rohan-sircar
I've cleaned up the code since but i haven't updated it. You can see that first i used a subject to create the observable, then i used a bounded asyncqueue instead. The latter allows backpressure.
Uploaded it*
lekan
@horlahlekhon
this is cool... i will give this a try.
Darren Bishop
@DarrenBishop
@lekan MO doesn’t really foster this model; you can do it by implementing an ‘entity’ that implements both Observer and Observable, that is some customised subject implementation, but I’d hazard to say that this arsenal of combinatory and operators are provided to obviate you doing that
The management bit is a tricky requirement; I managed to achieve something recently repurposing switchMap and there’s also publishSelector and some APIs that take a secondary observable as a parameter, where it’s events are treated as control signals
lekan
@horlahlekhon

@lekan MO doesn’t really foster this model; you can do it by implementing an ‘entity’ that implements both Observer and Observable, that is some customised subject implementation, but I’d hazard to say that this arsenal of combinatory and operators are provided to obviate you doing that

Noted.

Rohan Sircar
@rohan-sircar
MO doesn’t really foster this model; you can do it by implementing an ‘entity’ that implements both Observer and Observable, that is some customised subject implementation
The problem with subjects is how do you backpressure?
It's the same technique as using a concurrentqueue to build a backpressured observable, it's just impure.
Darren Bishop
@DarrenBishop
I think the one thing that would be really hard to migrate over is the ability to switch behaviour back and forth arbitrarily i.e. after flow has started based on receiving some event
Rohan Sircar
@rohan-sircar
You mean like state machines?
Darren Bishop
@DarrenBishop
I think scanXxx or ,accumulateXxx might give you some mileage there
@rohan-sircar yeah, ultimately I guess
Rohan Sircar
@rohan-sircar
State machines with scan can do exactly that. In fact i have written one but haven't uploaded it.
Darren Bishop
@DarrenBishop

The problem with subjects is how do you backpressure?

In practice, bufferIntrospective; if that was more of a conceptual question, incorporating purity, I’m not sure

Rohan Sircar
@rohan-sircar
Do you have an example?
With a subject, onNext returns immediately.
Darren Bishop
@DarrenBishop
...a ReplaySubject with bufferIntrospective 🤷🏾‍♂️
Are you sure?
Is that true for all Subject implementations with at least one subscriber?
Piotr Gawryś
@Avasil
onNext returns immediately with ConcurrentSubject that handles back-pressure with buffers
Other subjects return from onNext when all subscribers have returned
Rohan Sircar
@rohan-sircar
Okay, did not know that.
Darren Bishop
@DarrenBishop
😅 phew
Rohan Sircar
@rohan-sircar
Off to the scaladoc with me
kenbase
@kenbase:matrix.org
[m]
hello, newbie question, is this the right forum to ask a question about monix-kafka?
2 replies
Anirudh Vyas
@AnirudhVyas
hi there is there a monix connect project for rabbitmq?
Pau Alarcón
@paualarco
@AnirudhVyas atm there is no, I created an issue some time ago but work not has started yet monix/monix-connect#45
Trần Tiến Đức
@trantienduchn
Hi I'm new to Monix, how can I run multiple tasks in parallel and still get the result of all tasks even with error result. The Task.parMap or Task.parSequence will abort the whole process if one of the tasks is failed. But I still want to get the remaining successes and ignore the failed result
Oleg Pyzhcov
@oleg-py
@trantienduchn you can do task.attempt to get an Either[Throwable, A] if a task fails. From there it's a matter of putting few things together:
Task.parSequence(tasks.map(_.attempt) /* Don't fail */) // run in parallel
  .map(_.collect { case Right(a) => a }) // only retain successes in resulting list
Trần Tiến Đức
@trantienduchn
Great! Thanks!