-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Channel operators #88
Conversation
This extension function is useful for batch elaboration of live event stream. I.e. I don't consider adeguate a same extension for the |
I'm sorry I'm dragging feet on this PR. It is also related to #69 and is a part of a large piece of work to provide the same set of operations for |
Merged (with my own). I hope this helps. |
I am considering to port So Please keep this pull request in hold and send me your feedbacks. |
Ok. Here is a bit of additional information for your thought. The reason that Anyway, we could not name it |
Hi @elizarov, For many operations I choose a default coroutine context, often Unconfined. |
I've looked at the code and here are some thoughts in no particular order:
I've renamed
I'd suggest to rename I've changed context of I've rebased this pull request onto the current However, we don't yet support I've converted all I've pushed the result of those changes into a branch named |
However, this still leaves us with a number of questions: Most of the functions consume the incoming This poses a serious problem. Consider the producing coroutine (think of something done with I think we should limit operations on See, conceptually, the There is also an inefficiency that stems from the fact that Moreover, if you take a look at all intermediate operations that use |
What I'd suggest to do is, for now, leave only operations that completely consume their source ( |
Here is another solution that I actually like more. I'll make all functions on Just to recap, the key question that we are deferring here is what to do with concurrency. Shall channels be concurrent (multi-consumer) or single-consumer by default? Shall this distinction be reflected in the type (e.g. make MultileConsumerReceiveChannel a subclass or SingleConsumerReceiveChannel) or it should be left out as an implementation detail? Shall we also introduce better Rx-like abstractions and whether |
So, here's the summary of what I've done: I've introduced I've dropped I've dropped I've pushed the results to |
Here is another open question. So, we have a bunch of It somewhat devalues the desire to have the same names for all those operators as they are in defined for a So, let's get back to discussion on |
I think I explain my use case. A producer stores events in a channel, this event is unbounded, these occurs randomly and are potentially unbounded. I like if it should possible to define a strategy to limit events, but unfortunately something like |
@fvasco I see your use-case for |
In my use case exposed above I use a channel for one-to-one communication, I cosider a pipe a common event. |
Personal consideration: I seen the |
Oops. That's bad. We need to figure out what can be done to solve that issue. The best approach that I see is to get rid of
I find it all the time, too. My current thinking works in this direction:
Agree.
|
I don't think nothing better than "pipe", or something like this one.
I think
|
If "pipe" is the new type then
is a pipeline :) and we should support:
Moreover
will be a SPMC implementation. |
|
I've created a separate issue to discuss single-producer single-consumer channels (their naming and other design issues): #113 |
I plan to get back to this work. We've brainstormed the naming a little bit and decided that that receiver-close operation shall be naturally called |
However, we also need to introduce one new operation on receive channel. The operation that marks the channels as being in exlusive "ownership" of the reciver. This should protect from obvious mistakes like trying to |
It sounds like a However filter twice a channel should be legal, ie:
|
@fvasco This particular case you've posted when
But what happens if code at (A) fails with exception? When building pipelines with channels one has to be extremely careful to make sure that channel is always consumed fully. If you stop consuming the channel, then the producer just suspends forever, waiting. Of course, you can orchestrate all of this properly in your code, alway making sure to use I, so far, had convinced myself that for safety and reliability purposes we should only provide intermediate and terminal operations on channels that always consume the channel they are invoked on and their implementations should include all the proper measures to cancel the channel if something crashes. Every extension function that we provide on
I do believe that even Moreover, the very important feature of this kind of structure, is that it enables optimization via operator fusion. Consider To clarify, the plan is to use this "channel ownership" not like a simple tag, but to perform this fusion, e.g. when |
Hi @elizarov,
Sometimes I consider the current Channel implementation as a Following this reasoning, the effective Channel should be for one-to-one communication, so no explicit In such case the library should contains the terminal operators:
As finally consideration adding the |
A qiuck example related to #113
|
@fvasco You are right. It is in the scope of #113 We do have an option to introduce a separate single-consumer abstraction and explicitly represent it (statically) in the type system. Moreover, if we follow this path, then this single-producer/single-consumer should logically be the default, since that is what you'll want most of the time. This way, every time you have a channel (which is going to be single-consumer by default) and you want to use a "fan-out" pattern you'll have to invoke I'm trying to explore here is whether we can live without explicitly representing it in the type system and thus without requiring this So I want to prototype (first) this version where we don't have a separate |
I've manually merged this PR into To highlight: The |
No description provided.