-
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
Redesign ProducerJob extension of Job #127
Comments
Analogously to Java's Channel and Reactive Streams maybe we should introduce a What is the purpose of |
We will not have job on a plain channel. Only |
I looked better, job.disposeOnCompletion(channel) More in genera: Job and Channel are both disposable, so might be helpful review some design choices about "Disposable" interface. |
dropped/deprecated ActorJob/ProducerJob, fixes #127
all operators on ReceiveChannel fully consume the original channel using a helper consume extension, which is reflected in docs; removed `suspend` modifier from intermediate channel operators; consistently renamed channel type param to <E>; added two versions for xxxTo fun -- with MutableList & SendChannel; added tests for all channel operators; dropped/deprecated ActorJob/ProducerJob, fixes #127
In the current design
produce
coroutine builder returns an instance ofProducerJob
interface that extendsReceiveChannel
andJob
interfaces. The former gives access to all the channel operations, while the later contains Job-management API. Unfortunately, theJob
is aCoroutineContext.Element
and has operations likefold
that operate on coroutine contexts. It clashes with the proposed extensions onReceiveChannel
that treats it as a sequence of elements withfold
on them having a different meaning. See discussion in #88 for details.So the proposal is deprecate
ProducerJob
and replace it withProducer
interface that is aReceiveChannel
(to enable convenient pipelining) and hasjob
as a property for cases where it is needed.Now, the most common use-case for which you might need to access a producer's job is to cancel it when you don't need it. To make it easier, the proposal is to add
cancel
operation onReceiveChannel
interface directly. The semantics ofcancel
for aReceiveChannel
if that it signals that no more elements are going to be received from this channel and the producer of the channel must abort if it is still running (send
will throwCancellationException
). All the built-in pipelining operations likefilter
,map
, etc onReceiveChannel
(see #88) are going to always cancel the receive channel when they are done (even if they crash), so this way an operational pipeline that starts withproduce { ... }
and continues with one of those pipelining operations will always cancel the producer without a risk of a producer leak if something crashes downstream.The text was updated successfully, but these errors were encountered: